I'd like to take a folder of images of various sizes and have them cropped into a 600x600 grid square, cut out from the middle of the image. Is there a program that can automatically resize and crop to these dimensions, and then output as a compressed .png file? For images that are smaller than 600x600, I'd like the program to increase the size of the image to that dimension.
Photoshop's Batch command can do this. You would essentially 'record' yourself performing the crop etc once, then run the recording on all the files you want. If you want to automatically resize the smaller images you would have to do a little scripting.
Irfanview also has a comprehensive image batch processor but might require a bit of experimentation to get the results you want.
ImageMagick let's you run commands in a windows command window. You need to be comfortable with creating Dos batch files.
For an example see the last post in this discussion: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=21112
Relevant example from this forum post:
@echo off cd C:\Users\user\Desktop\New\New folder convert *.jpg -fuzz 10%% -trim -write %%02d_trim.png -scale "x1!" txt: convert *_trim.png -crop 209x329+0+0 -fuzz 10%% -trim +repage %%02d_left.png convert *_trim.png -crop 173x336+227+0 -fuzz 10%% -trim +repage %%02d_right.png @pause
First I thought you wanted batch resize, which many programs can do. But then I realized you want to do a combination of resizing and cropping, and you want the computer to calculate how to best cut out 600x600 pixels from the image dynamically.
It is because it is not a "one true solution" kind of task, as it is usually human judgement call, how to crop the image, so it can only be done by bootstrapping certain conditions. For example, look at aspect ratio, and always resize the shortest dimension to X and crop Y (centered/right/left) pixels. If I read your statement right, you want to crop 600 pixels from X and Y centered in both dimensions, if both dimensions are 600 or more. And only resize to 600 if one dimension is smaller than 600?
I've long wanted to add a feature like this to my program "Image View Plus More", and I guess the feature settings should be something like: - crop size: w x h - align width: center/left/right - align height: center/left/right - resize: no/if smaller than/if bigger than/both
Any more settings you'd need?
Update: I am now done programming this feature into Image View Plus More 2.4:
How-to: install, drag'n'drop the images you want to crop into it, "save all to new folder", and give it a basename or % to use the original filename, and then in the next dialog select "autocrop" and fill the boxes for width and height, and select alignment "center" for height and width, and check "resize if smaller".
I made a tutorial how to do it:
The solution to the OP problem: http://www.youtube.com/watch?v=wBc1s6zuDJM
Another example: http://www.youtube.com/watch?v=3nFrnaefsqA
If you like programing, you can use Python (computer language) and an excellent library know has PIL to crop, re-size, plot histograms, get individual pixel vales, etc... on a programmatic level. Thus you can easily write a simple script to find all images in a folder and perform the operation.
This code should do exactly what you want and should process a couple pictures per second, depending on the image size:
#Python 2.7, PIL 1.1.7 import Image import glob import os #Function to resize image, preserving aspect ratio def resizeAspect(im, size): w,h = im.size aspect=min(size/float(w), size/float(h)) return im.resize((int(w*aspect),int(h*aspect)),Image.ANTIALIAS) imgList=glob.glob('C:/icons/*.png') #Find all png images in a directory for img in imgList: #Loop through all found images im = Image.open(img) #open the image print "resizing:",os.path.basename(img) w,h = im.size #Get image width and height if min(w,h)<600: #Check if either dimension is smaller then 600 im=resizeAspect(im,(600,600)) #Re-size Image w,h = im.size #update image size center = [int(w/2.0),int(h/2.0)] #Calculate Center box = (center-300, center-300, center+300, center+300) #Defines a box where you want it to be cropped croppedIm = im.crop(box) #Crop the image #croppedIm.show() #Show the cropped image fileName, fileExtension=os.path.splitext(img) croppedIm.save(fileName+'_crop.png', "PNG") #Save the cropped image
When you start working on the programmatic level, then the sky is the limit! It is even possible to detect faces and crop around the face, allowing you to intelligently crop thousands of photos...
ThumbsPlus can do what you request. On the Image menu, select Batch Process or press F12 and answer the interactive prompts. You can add multiple operations to a set and save it for immediate use as well as future use. In the future, just access the set name you previously configured to automatically run it on a directory or selection of photos, or even an entire directory tree.
When building the set, you are provided a sample picture to illustrate the option you have added to the operations.
Be careful in building the set, since the order of operations is important.
Sizzlepig.com is an online tool that will do this easily, you can set the "blueprint" size to be 600x600, and then have it crop center all the images.
For the part "For images that are smaller than 600x600 I'd like the program to increase the size of the image to that dimension." I'd highly recommend NOT attempting to upscale the images, but trying to find a higher quality source to work with. I know it's not always possible, but it will result in a much higher quality output than attempting to upscale.
(I work for sizzlepig, but its still a great tool)
Irfanview can do what you are asking for. Its batch mode has a lot of options.
Here is a small tutorial link: http://gd.tuwien.ac.at/graphics/irfantut/batchcon.html
Irfanview can do this but takes a bit of setting up.
Use the Batch conversion option. Choose "PNG" as your output format. Click on the "options" button next to the output format and choose the compression that you want and click OK
Tick the box that says "Use advanced option" then click the "advanced" button
You'll see this window
Set up the resize with shortest side 600. Make sure you tick "preserve aspect ratio" and "use resample function". Untick "Don't enlarge smaller images"
If you are dramatically reducing the size of your original images then you may want to tick the "sharpen" box and add a value. My requirement was for images of 150x150 size and I found they needed a sharpen value of about 20 to match the quality of image I was getting from photoshop. For your 600x600 images you may not need a sharpen value - so you can untick that option.
Instead of using "crop" use the "canvas size" setting - make sure you tick the option
Click on the "settings" button next to the canvas size option. You'll see this window
Select method 2 and width and height as 600. Choose the "center" option for the anchor
The canvas colour doesn't matter as it won't actually add an image border
Now on the advanced screen again tick the box next to "custom processing order" and make sure that the "resize" is first on the list - i.e. so that the resize is done before the crop.
Make sure you've selected the files you want to convert, set up the output directory and then click on "start batch"
There is a utility with multiple options available at http://pixresizer.software.informer.com/
This is good software. Good means, easy to use and faster in work. As I do photography, I am using it to process images in batch. Many times I need to reduce the size of pics to share them over the internet. I also tried some other software too, but found this one good. (I am not associated with this company.)