Re: dynamic mixing of primitives and background picture - semi-gui cropping utility

On Nov 8, 2009, at 10:33 AM, <postdoc38 yahoo fr> <postdoc38 yahoo fr> wrote:

Dear Fellow Gtk-Perlers,

See my attempt below at a "semi-gui" jpeg lossless cropping utility. The idea is to cycle through a few jpeg files, set the crop parameters by moving sliders with cursor keys, and crop the jpegs losslessly.

y program works, but is quite "Mc Gyver"-like. I go back and forth between perlmagick and gtk2 to draw the cropping rectangle and the background picture. And I think it should be much faster to only redraw the part of the background were the previous crop rectangle was instead of redrawing the whole thing.

A little background: I have a bunch of jpegs that are produced by a camera shooting old slides (a cheap and dirty slide scanner). They all have black borders due to the copying setup. What I aim is to check that the crop parameters are correct on each picture. Lossless means cropping along multiple of 8 pixels using appropriate outside utilities (namely jpegtran).

Thanks for any input!



You forgot "use strict"!

Instead of hard-coded numeric key values, you should use the keysyms hash.

use Gtk2::Gdk::Keysyms;


   if ($key_val == $Gtk2::Gdk::Keysyms{GDK_Up}) {


(Or mess around with an accelerator table. For what you have, the key value processing is probably nice and user-friendly, as it requires no modifier keys.)

Instead of connecting to delete-event to quit the main loop, do that in the destroy signal on the window. Then you can add "q" as a hotkey, and just call $window->destroy and the right thing will happen.

In auto_crop(), should check $color for an empty value; i loaded up a jpeg that didn't have a border, and imagemagic returned no border for it, causing a bunch of uninitialized value warnings.

Oh, actually my imagemagick is too old to support the special info: name. You might want to do a version check on convert before doing that stuff.

If you want to learn about gdk, you can try to do the drawing all in the app instead of bouncing back and forth with imagemagick. You could also take the slow route and draw on the pixels in perl, but that's a bit icky.

It's all very complicated and would take a scientist to explain it.
  -- MST3K

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]