Page 1 of 1

Convert images to different format only if size is greater..

Posted: 2012-01-05T14:42:26-07:00
by timbrewolf
Hey everyone - I've seen ImageMagick before, but have a specific project I'm struggling to find a solution for and this seems as close as I have gotten.

I have 10,000 files in a folder, for example - CMYK TIFF that I want to convert to PNG. However, I don't want to convert all of them, only ones that are larger than 1000pixel on either height or width.

My first thought was that I could do this with the -resize 1000^< (windows user). However, even if that kinda works, it ends up resizing the image and I don't really want to resize the image, I just want to convert it.

I have searched through the forums for skipping, ignoring, and such but I can only find the ability to resize to a specific size, not just ignoring files of a smaller size. Any help would be greatly appreciated!

TW

Re: Convert images to different format only if size is great

Posted: 2012-01-05T14:49:03-07:00
by fmw42
I think you will have to write a script (Bat file) to loop over all your images, compute the image sizes as variables using -format "%w" and -format "%h" and use a conditional test on the image sizes to determine if you want to convert them or skip them.

See http://www.imagemagick.org/Usage/windows/ as I am not a windows user and can only show you how to do it in Unix/IM syntax.

Re: Convert images to different format only if size is great

Posted: 2012-01-05T14:52:42-07:00
by timbrewolf
Wow thanks for the super-quick reply.

I hadn't thought of that, but you're right - since .bat files will allow integer variables. I always forget that.

If I'm able to write that, I'll come back and post it if it can help anyone else.

Re: Convert images to different format only if size is great

Posted: 2012-01-05T14:59:15-07:00
by Bonzo
There might be a batch file on my site that will get you started: http://www.rubblewebs.co.uk/imagemagick/batch.php