Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Transform an image into different aspect ratios
#5
Quote:because you removed the thing that describes the input arguments by commenting in out, instead of making it an empty list. But it's better to keep it in an have an image argument to your plugin, so you can work even if several images are open in Gimp:

Ah ok! I thought I could comment it out without any harm. Do I need at least one parameter, or is an empty bracket okay too?


Quote:So, given this the code sorta works(*) but:
  • you save the image with its initial extension (say, PNG) even if you enforce the jpeg format.

I only open and save jpegs so that wont be an issue.
  • Quote:image is saved in the "current directory" which is certainly not what you want in the general case. Once you have generated the new file name, you probably want to create a full path by putting it at the end of the directory of the source image (that you obtain with os.path.dirname()) using os.path.join().


Yeah, that was my plan Smile


Quote:This may provides a working script(*), but then, DRY: Don't Repeat Yourself: there is very little difference between the 4:3 and 3:2 image ratios: just the name of the image and the image size, so normally both cases can be treated with the same function to which you pass the output file path and the image dimensions. And while you are making functions, you can make one that takes the input path, the aspect ratio, and return a complete output path with adequate extension. So you can test it independently.


For the current transformations it wont be necessary to repeat, thats right. Functions will be my next step to avoid it in the future. Thanks for the help! Smile
Reply


Messages In This Thread
RE: Transform an image into different aspect ratios - by SpaceMonkey - 01-29-2024, 10:59 PM

Forum Jump: