Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Auto resizing images with varying dimensions.

  1. #1
    Join Date
    Feb 2007
    Location
    Sebring, Florida USA
    Beans
    184

    Auto resizing images with varying dimensions.

    I really don't know what forum to drop this thread in so pardon me if this is the incorrect forum.

    I have a huge folder of jpg images that vary greatly in dimensions. I have a situation where no images can be over 900 wide and 675 high. Is there a way (other than manually one at a time) to go through the folder of images, locate all that are larger than 900w and/or 675h and reduce them proportionally to meet the maximum 900x675 parameter? This reduction needs to create the largest possible proportionally resized image inside the 900x675 parameter

    I could do this if all images were the same dimensions and were larger than 900x675 but unfortunately that is not the case. There are many oddball sizes and many that meet the parameters in one direction but not the other or vice-versa. There are also square pics. Lastly, the folder also contains many pictures already inside the 900x675 requirement that need to be ignored.

    Is there an app or script out there that can handle this?
    Last edited by Trapper; October 12th, 2011 at 02:33 PM. Reason: Incorrect spelling
    Control is a wonderful thing ... but only if you have your own.
    LM13 with MATE DE on:
    BioStar MCP6P-M2 Motherboard * NVIDIA GeForce 6150/nForce 430 Video * AMD Sempron LE1100 1.9GHZ CPU * 2GB RAM * 160 GB SATA2 HD * 320 GB IDE HD

  2. #2
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Auto resizing images with varying dimensions.

    Quote Originally Posted by Trapper View Post
    I really don't know what forum to drop this thread in so pardon me if this is the incorrect forum.

    I have a huge folder of jpg images that vary greatly in dimensions. I have a situation where no images can be over 900 wide and 675 high. Is there a way (other than manually one at a time) to go through the folder of images, locate all that are larger than 900w and/or 675h and reduce them proportionally to meet the maximum 900x675 parameter? This reduction needs to create the largest possible proportionally resized image inside the 900x675 parameter

    I could do this if all images were the same dimensions and were larger than 900x675 but unfortunately that is not the case. There are many oddball sizes and many that meet the parameters in one direction but not the other or vice-versa. There are also square pics. Lastly, the folder also contains many pictures already inside the 900x675 requirement that need to be ignored.

    Is there an app or script out there that can handle this?
    ImageMagick's "convert" or "mogrify" commands will handle this. ImageMagick is in your standard repository.

  3. #3
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Auto resizing images with varying dimensions.

    Imagemagick has a variety of geometry options. You might find this document a good starting point. The "fill" option is probably the one you want.

    I posted a quick-and-dirty bash script to resize all the images in a directory here. Just modify the SCALE variable to fit your needs.
    Last edited by SeijiSensei; October 12th, 2011 at 04:57 PM.

  4. #4
    WasMeHere is offline Iced Almond Soy Ubuntu, No Foam
    Join Date
    May 2008
    Location
    Sverige
    Beans
    1,133

    Re: Auto resizing images with varying dimensions.

    +1 for ImageMagick

    It is a great tool for batch work, and the tutorials on the internet are very good

    Have fun
    Olle

  5. #5
    Join Date
    Feb 2007
    Location
    Sebring, Florida USA
    Beans
    184

    Re: Auto resizing images with varying dimensions.

    Wow. This is obviously more complicated to do than I realized. With my lack of knowledge in the area it's probably going to be easier and faster for me to just manually go through the 8000+ images with my viewer/editor, find the ones that qualify for resizing and resize them.
    Control is a wonderful thing ... but only if you have your own.
    LM13 with MATE DE on:
    BioStar MCP6P-M2 Motherboard * NVIDIA GeForce 6150/nForce 430 Video * AMD Sempron LE1100 1.9GHZ CPU * 2GB RAM * 160 GB SATA2 HD * 320 GB IDE HD

  6. #6
    Join Date
    Feb 2007
    Location
    Sebring, Florida USA
    Beans
    184

    Re: Auto resizing images with varying dimensions.

    Well, I "think" I may have figured it out but I am still testing this. It appears to only resize images that are over 900 wide or 675 high, which is what I am wanting.

    This is simply run in a terminal from the folder containing the images.


    Code:
    $ mogrify -resize '900x675>' *.jpg

    I will continue testing and post my findings tomorrow.
    Control is a wonderful thing ... but only if you have your own.
    LM13 with MATE DE on:
    BioStar MCP6P-M2 Motherboard * NVIDIA GeForce 6150/nForce 430 Video * AMD Sempron LE1100 1.9GHZ CPU * 2GB RAM * 160 GB SATA2 HD * 320 GB IDE HD

  7. #7
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Auto resizing images with varying dimensions.

    I hope you kept backups! Mogrify overwrites the original images. I think you have the right syntax, so I'm hoping it all works out well for you!

    The script I wrote uses "convert" instead of "mogrify" and stores the resized images into a separate subdirectory to insure that the originals aren't changed in any way.

  8. #8
    Join Date
    Feb 2007
    Location
    Sebring, Florida USA
    Beans
    184

    Re: Auto resizing images with varying dimensions.

    Quote Originally Posted by SeijiSensei View Post
    I hope you kept backups! Mogrify overwrites the original images. I think you have the right syntax, so I'm hoping it all works out well for you!

    The script I wrote uses "convert" instead of "mogrify" and stores the resized images into a separate subdirectory to insure that the originals aren't changed in any way.
    Ha! Yup, I have an understanding of what mogrify does to file and kept a backup of everything I processed.

    I did work with your script a bit and adjusted it for my usage. I set the SCALE variable as SCALE='900x675>'

    That does scale my images correctly and places them in the NEWDIR ..... but it also gives me an original sized copy of all the images that were in IMAGEDIR too. Uniquely, the copies of the original files from the IMAGEDIR are the same dimensions as the originals but the actual file size is a wee bit smaller than the originals. This extra file behavior does not transpire with "mogrify". Perhaps it has something to do with '900x675>'
    Last edited by Trapper; October 13th, 2011 at 02:11 AM. Reason: More comments.
    Control is a wonderful thing ... but only if you have your own.
    LM13 with MATE DE on:
    BioStar MCP6P-M2 Motherboard * NVIDIA GeForce 6150/nForce 430 Video * AMD Sempron LE1100 1.9GHZ CPU * 2GB RAM * 160 GB SATA2 HD * 320 GB IDE HD

  9. #9
    WasMeHere is offline Iced Almond Soy Ubuntu, No Foam
    Join Date
    May 2008
    Location
    Sverige
    Beans
    1,133

    Re: Auto resizing images with varying dimensions.

    I'm glad that you are successful with ImageMagick

    Quote Originally Posted by Trapper View Post
    ... Uniquely, the copies of the original files from the IMAGEDIR are the same dimensions as the originals but the actual file size is a wee bit smaller than the originals. This extra file behavior does not transpire with "mogrify". Perhaps it has something to do with '900x675>'
    I would keep the original files (maybe move or copy via the shell script) without processing. Otherwise your pictures might be downgraded by a 'lossy conversion'.

  10. #10
    Join Date
    Feb 2007
    Location
    Sebring, Florida USA
    Beans
    184

    Re: Auto resizing images with varying dimensions.

    Quote Originally Posted by Olle Wiklund View Post
    I'm glad that you are successful with ImageMagick

    I would keep the original files (maybe move or copy via the shell script) without processing. Otherwise your pictures might be downgraded by a 'lossy conversion'.
    Yes, I am keeping the original files rather than the same dimension duplications for that very reason however the behavior of "convert" with this script, as it is, makes me quite reluctant to even use it. It's creating two new images from every one it processes. Well, I have 8000+ images to process. I'm going to end up with the original 8000+ and another 16,000 images. I'm also going to have to make up a function to separate the new created resized images from the newly created same size images.

    I'm probably just going to copy the original 8000 to a work folder, run the "mogrify" operation on it and then run a renaming function on the new files.
    Control is a wonderful thing ... but only if you have your own.
    LM13 with MATE DE on:
    BioStar MCP6P-M2 Motherboard * NVIDIA GeForce 6150/nForce 430 Video * AMD Sempron LE1100 1.9GHZ CPU * 2GB RAM * 160 GB SATA2 HD * 320 GB IDE HD

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •