Time to be with your loved ones

Time to be with loved ones

by sat

submit your photo


Hall of Fame
View past winners from this year

Please participate in Meta
and help us grow.

Take the 2-minute tour ×
Photography Stack Exchange is a question and answer site for professional, enthusiast and amateur photographers. It's 100% free, no registration required.

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 re size 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. Thanks for your time.

share|improve this question
    
I checked my Irfanview, and its batch crop is static with only the option to start from corners and a fixed offset. It cannot do the centering and the conditional resize asked for by the OP. It is not fit for variable image sizes. –  Michael Nielsen Sep 13 '12 at 10:49
    
I was very hopeful XnConvert might do what you're after but like IrfanView it won't do a centred crop on arbitrary image sizes. –  Mark Whitaker Oct 3 '12 at 7:44
add comment

9 Answers

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.

share|improve this answer
add comment

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
share|improve this answer
    
Its best if the relevant parts of external resources are quoted or summarized here. External links can potentially go offline at any time, invalidating an answer that just contains a link. The link you provided has an answer, however I'd ask that you quote the relevant command here in your answer to make it more viable. –  jrista Sep 13 '12 at 1:17
add comment

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:

http://www.sequoiagrove.dk/tools.php

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

share|improve this answer
    
See my answer, I wrote out the code in python. –  Onlyjus Sep 12 '12 at 19:17
1  
Yes now it is not so static, but are you sure the OP is interested in programming his image editing? –  Michael Nielsen Sep 12 '12 at 20:41
    
I have no idea. The OP just asked for a program, so I wrote one. –  Onlyjus Sep 12 '12 at 20:52
    
As you see I now added the feature, and I have ideas for improvements, like "show by example" (on the currently viewed photo), so you cant have to limit yourself to centered or aligned to the edges. Ofc I'd have to figure out how to generalise that example to different aspect ratios and sizes. –  Michael Nielsen Sep 13 '12 at 7:05
    
Nice! What is your program written in and is the source available? –  Onlyjus Sep 13 '12 at 12:02
show 2 more comments

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[0]/float(w), size[1]/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[0]-300, center[1]-300, center[0]+300, center[1]+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...

[updated 09/12/2012]

share|improve this answer
add comment

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.

share|improve this answer
    
Thanks for the edit! –  jrista Nov 17 '12 at 16:23
add comment

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)

share|improve this answer
    
Please see faq. It's okay to mention your own things here, but you need to say so. –  mattdm Nov 16 '12 at 18:40
1  
sorry about that, thanks for mentioning it. –  jeremy Nov 16 '12 at 18:41
1  
Cool. Welcome to the site, and stay around and answer and ask some other questions. :) –  mattdm Nov 16 '12 at 18:43
add comment

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

share|improve this answer
add comment

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

Irfanview advanced settings

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

Irfanview canvas size options

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.

Click OK

Make sure you've selected the files you want to convert, set up the output directory and then click on "start batch"

share|improve this answer
add comment

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.)

share|improve this answer
    
Is the software any good? Why? Are you associated with the company? –  Paul Cezanne Jul 26 '13 at 11:37
    
Hi Paul, Yes 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. I also tried some other software too, but found it good. No!, I am not associated with this company. –  Mahesh Mankar Jul 26 '13 at 12:01
    
Mahesh, can you take your comments and edit your answer? Not everybody reads the comments. And tell us more and more about it, we'd love to know! –  Paul Cezanne Jul 26 '13 at 13:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.