Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > cropping images

Reply
Thread Tools

cropping images

 
 
Roedy Green
Guest
Posts: n/a
 
      08-18-2011
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)
 
Reply With Quote
 
 
 
 
Thomas Richter
Guest
Posts: n/a
 
      08-18-2011
On 19.08.2011 01:18, Roedy Green wrote:
> 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


 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      08-19-2011
On Thu, 18 Aug 2011 16:18:34 -0700, Roedy Green
<(E-Mail Removed)> wrote, quoted or indirectly quoted
someone who said :

> 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)
 
Reply With Quote
 
Joshua Cranmer
Guest
Posts: n/a
 
      08-19-2011
On 8/18/2011 6:18 PM, Roedy Green wrote:
> 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.

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-19-2011
On Thu, 18 Aug 2011 20:29:35 -0700, Peter Duniho
<(E-Mail Removed)> wrote, quoted or indirectly quoted
someone who said :

>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)
 
Reply With Quote
 
Tom Anderson
Guest
Posts: n/a
 
      08-19-2011
On Thu, 18 Aug 2011, Roedy Green wrote:

> On Thu, 18 Aug 2011 16:18:34 -0700, Roedy Green
> <(E-Mail Removed)> wrote, quoted or indirectly quoted
> someone who said :
>
>> 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.


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

--
Punk's not sexual, it's just aggression.
 
Reply With Quote
 
Tom Anderson
Guest
Posts: n/a
 
      08-19-2011
On Thu, 18 Aug 2011, Peter Duniho wrote:

> On 8/18/11 4:18 PM, Roedy Green wrote:
>
>> 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?

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

--
Punk's not sexual, it's just aggression.
 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      08-19-2011
In article <(E-Mail Removed)>,
Roedy Green <(E-Mail Removed)> wrote:

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

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
Thomas Richter
Guest
Posts: n/a
 
      08-19-2011
On 19.08.2011 02:34, Roedy Green wrote:
> On Thu, 18 Aug 2011 16:18:34 -0700, Roedy Green
> <(E-Mail Removed)> wrote, quoted or indirectly quoted
> someone who said :
>
>> 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 pointed you to a pair of two utilities which do that rather nicely and
cost $0. Where is the problem?
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-20-2011
On Fri, 19 Aug 2011 11:28:46 +0100, Tom Anderson
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
said :

>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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cropping an image Darrel ASP .Net 3 04-23-2006 09:33 PM
Cropping a batch of images Terry Pinnell Digital Photography 11 01-29-2006 12:29 PM
.Net control for uploading, cropping and transforming graphics file FrankV ASP .Net 0 11-08-2005 03:28 AM
JAI example of cropping Andrew Neiderer Java 2 09-17-2005 11:31 AM
Cropping Images on Linux/Windows Bernd Digital Photography 15 01-06-2004 11:16 PM



Advertisments