cropping images

R

Roedy Green

I have 1200 square PNG images of national flags in various sizes. I
would like to crop them to rectangles. I thought of writing a
one-shot java utility for the purpose, then I wondered if I would be
reinventing the wheel. Suggestions?
--
Roedy Green Canadian Mind Products
http://mindprod.com
The modern conservative is engaged in one of man’s oldest exercises in moral philosophy; that is,
the search for a superior moral justification for selfishness.
~ John Kenneth Galbraith (born: 1908-10-15 died: 2006-04-29 at age: 97)
 
T

Thomas Richter

I have 1200 square PNG images of national flags in various sizes. I
would like to crop them to rectangles. I thought of writing a
one-shot java utility for the purpose, then I wondered if I would be
reinventing the wheel. Suggestions?

pngtopnm | pnmcrop
 
R

Roedy Green

I thought of writing a
one-shot java utility for the purpose, then I wondered if I would be
reinventing the wheel. Suggestions?

I have been googling and trying out various utilities that promise to
do the job, but even a $60 utility can't see to get this right.

I get quite annoyed when a vendor advertises a product as free when it
isn't or that it will do some task when it does not even attempt it.
It seems there is no penalty for lying.
--
Roedy Green Canadian Mind Products
http://mindprod.com
The modern conservative is engaged in one of man’s oldest exercises in moral philosophy; that is,
the search for a superior moral justification for selfishness.
~ John Kenneth Galbraith (born: 1908-10-15 died: 2006-04-29 at age: 97)
 
J

Joshua Cranmer

I have 1200 square PNG images of national flags in various sizes. I
would like to crop them to rectangles. I thought of writing a
one-shot java utility for the purpose, then I wondered if I would be
reinventing the wheel. Suggestions?

ImageMagick can do a lot of stuff with image manipulation, especially
combined with some simple shell scripts.
 
R

Roedy Green

If you know in advance that every image will need the same cropping
applied to it, then I think the batch features in the other programs are
more likely to suit your needs.

I think there are 4 different croppings, one for each directory. I
will find out if I need something smart to chop off the transparent
border at differently centred images. One catch is there is a feather
edge transparency.

I found an off-by-one bug in Batch It Ultra, but at least the author
seems to be interested in tracking it down.

I am so often tempted to write my own utilities simply because other
people's code is invariable buggy, or awkward to use, and you can
waste so much time trying to get the authors to fix it.

What is really getting annoying is people writing completely bogus
feature lists.

On an unrelated project, I downloaded what was advertised to be free
drivers for a foot pedal only to discover it was an expensive program
to scan your drivers and tell you which ones were out of date.
I want revenge!
--
Roedy Green Canadian Mind Products
http://mindprod.com
The modern conservative is engaged in one of man's oldest exercises in moral philosophy; that is,
the search for a superior moral justification for selfishness.
~ John Kenneth Galbraith (born: 1908-10-15 died: 2006-04-29 at age: 97)
 
T

Tom Anderson

I have been googling and trying out various utilities that promise to do
the job, but even a $60 utility can't see to get this right.

Really? Wow.

Wait, is that 60 dollars Canadian?
I get quite annoyed when a vendor advertises a product as free when it
isn't or that it will do some task when it does not even attempt it. It
seems there is no penalty for lying.

I guess you don't read the news much, huh.

Fortunately, there is a place which still values honesty, hard work, and
doing the best job you can. It's called open source, and there we find:

http://www.imagemagick.org/script/index.php

Costs nothing, and a suitable invocation of the convert command will do
what you want. ImageMagick is pretty simple to use for single images; it
gets a bit more more twisted for multiple images, so you can either figure
it out, or call it repeatedly from a batch script or something.

tom
 
T

Tom Anderson

There are _tons_ of image manipulating programs out there. Nearly all
of them support some kind of cropping.

The problem I found was that none provided an efficient workflow to deal
with a large number of images where each image needed to be cropped
differently (or at least, a large number of the set did).

Irfanview and ImageMagick are both well-known utilities, and they offer
decent batch processing features. But neither allow per-image
customization of the batch processing.

I wonder if ImageMagick could do this indirectly by using a mask. I'm not
sure how you'd generate the masks, though.

Even if you could do this, driving ImageMagick with a shell script is
still going to be easier.
A few year ago I got tired of cropping thousands of images in Photoshop
one at a time (too much clicking), so I wrote a very simple utility to
do it for me. The main feature of the tool is that it will crop,
optionally scaling the image, with a minimum number of clicks.

If you're curious, you can check it out here:
http://harveyosity.org/dragncrop/index.html

I suppose your problem is really not manipulating a large number of
images, but entering a large number of crop rectangles. If you had the
rectangles in a file already, bash+convert could do the job easily.

I've occasionally been pained by the absence of an easy way to script GUI
interactions with images. I spend ages going through holiday pictures
choosing which of N shots of a scene i want to post on Flickr; if i had a
simple way of popping up two images and prompting myself to click the
better one, i could use that as a comparison function in a sort, and
largely mechanise the decision process.

tom
 
J

John B. Matthews

Roedy Green said:
I have 1200 square PNG images of national flags in various sizes. I
would like to crop them to rectangles. I thought of writing a
one-shot java utility for the purpose, then I wondered if I would be
reinventing the wheel. Suggestions?

I use ImageJ's built-in macro language to resample large numbers of
images using Image > Adjust > Size... (25.2.6), but Image > Crop...
(25.8) is available, too.

<http://rsbweb.nih.gov/ij/>
<http://rsbweb.nih.gov/ij/developer/macro/macros.html>
<http://rsbweb.nih.gov/ij/docs/guide/userguide-Part-V.html>
 
T

Thomas Richter

I have been googling and trying out various utilities that promise to
do the job, but even a $60 utility can't see to get this right.

I pointed you to a pair of two utilities which do that rather nicely and
cost $0. Where is the problem?
 
R

Roedy Green

Really? Wow.

Wait, is that 60 dollars Canadian?

A Canadian dollar is worth about $1.01 US just now. It dropped down
from $1.05 when the debt ceiling crisis resolved.
--
Roedy Green Canadian Mind Products
http://mindprod.com
The modern conservative is engaged in one of man's oldest exercises in moral philosophy; that is,
the search for a superior moral justification for selfishness.
~ John Kenneth Galbraith (born: 1908-10-15 died: 2006-04-29 at age: 97)
 
R

Roedy Green

I pointed you to a pair of two utilities which do that rather nicely and
cost $0. Where is the problem?

they don't run under windows, or at least not with minimal fuss the
way most windows utilities do.
--
Roedy Green Canadian Mind Products
http://mindprod.com
The modern conservative is engaged in one of man's oldest exercises in moral philosophy; that is,
the search for a superior moral justification for selfishness.
~ John Kenneth Galbraith (born: 1908-10-15 died: 2006-04-29 at age: 97)
 
N

Nigel Wade

they don't run under windows,

apparently they do:
http://www.imagemagick.org/Usage/windows
or at least not with minimal fuss the
way most windows utilities do.

and exactly how many of the minimal-fuss Windows utilities that you have
installed and tried so far have provided you with the functionality that
you require?

At some point you may realize that it's a more cost-effective use of
your time to install something which you know works, even if it will
take up some of your time, rather than continue to waste time installing
minimal-fuss applications which don't work.
 
J

Jeff Higgins

The utilities posted by Thomas were pngtopnm, pnmcrop
which are part of the netpbm suite,
not ImageMagick.

It appears (quick google) that netpbm was runnable on windows at
one stage, and may still be.

However, since netpbm is essentially built on
the principle of pipelining the components
together, Unix is very much its natural habitat.
I'm sure that the Cygwin environment for Windows is not for everyone
but installing a basic Cygwin and the libnetpbm certainly qualifies
as painless in my opinion.
<http://www.cygwin.com/packages/>
 
N

Nigel Wade

The utilities posted by Thomas were pngtopnm, pnmcrop
which are part of the netpbm suite,
not ImageMagick.

Ah, my mistake. Unfortunately I'd been following this thread last week
when ImageMagick was suggested by several people. The actual apps.
suggested by Thomas had been trimmed from this sub-thread, and I'd
mistakenly assumed they were referring to ImageMagick.
It appears (quick google) that netpbm was runnable on windows at
one stage, and may still be.

However, since netpbm is essentially built on
the principle of pipelining the components
together, Unix is very much its natural habitat.

Probably so. I've never used them. I tend to stick to GIMP and
ImageMagick when I need to do image manipulation on Linux.

I still think Roedy would be best served by installing ImageMagick. If
not on Windows, then in a Linux virtual machine hosted by Windows. I'm
sure that it would be more productive in the long run than testing more
and more Windows utilities that promise everything, yet deliver very
little. It's also not going to carry a virus/trojan payload -
downloading and installing random Windows utilities off the 'net is a
route to perdition.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

string case clauses 7
Locale.getDefault bug in JDK 1.7 28

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top