For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > October 2004 > rotate a Tk::Image by 90 degrees









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author rotate a Tk::Image by 90 degrees
Torsten Mohr

2004-10-20, 4:05 pm

Hi,

I load a JPEG image using Tk::JPEG::Lite and i want to turn
that image clockwise or counterclockwise by 90 degree.

What would be the best way to do that?

Is there some built-in function for that?

Or do i need to use get() and put()?

Can i get the data() of the image into a string and do
the conversion faster there?


Thanks for hints,
Torsten.

Slaven Rezic

2004-10-20, 4:05 pm

Torsten Mohr <tmohr@s.netic.de> writes:

> Hi,
>
> I load a JPEG image using Tk::JPEG::Lite and i want to turn
> that image clockwise or counterclockwise by 90 degree.
>
> What would be the best way to do that?
>
> Is there some built-in function for that?
>
> Or do i need to use get() and put()?
>
> Can i get the data() of the image into a string and do
> the conversion faster there?
>


Unfortunately data() gives you an Tcl list of list, which you have to
parse, so it's not that fast. You have to experiment whether it's
actually faster than get() and put().

The easiest way is to use another module like GD or Image::Magick or
external programs like netpbm to do the rotation.

Regards,
Slaven

--
Slaven Rezic - slaven <at> rezic <dot> de
BBBike - route planner for cyclists in Berlin
WWW version: http://www.bbbike.de
Perl/Tk version for Unix and Windows: http://bbbike.sourceforge.net
$_@_.%_

2004-10-21, 8:56 am


Torsten Mohr <tmohr@s.netic.de> wrote in message-id:
<cl67si$bqt$1@schleim.qwe.de>
>
>Hi,
>
>I load a JPEG image using Tk::JPEG::Lite and i want to turn
>that image clockwise or counterclockwise by 90 degree.
>
>What would be the best way to do that?
>
>Is there some built-in function for that?
>
>Or do i need to use get() and put()?
>
>Can i get the data() of the image into a string and do
>the conversion faster there?
>
>
>Thanks for hints,
>Torsten.


If you are using a canvas to display the image(s), perhaps this widget
could help.

Tk::RotCanvas - Canvas widget with arbitrary rotation support



Torsten Mohr

2004-10-21, 4:02 pm

Hi,

thanks for the hints. I was a bit unprecise, i wrote
a script to view the pics that i took with my digital
camera, so i want to turn them permanently, save them
back to disk.

I first used jpegtopnm | pnmrotate | pnmtojpeg but
went on to use GD, as it is more portable. But the
qualtiy does not look good, though i chose a quality
of 90 and the file size increases.

Has anybody got a solution to turn the picture in the
filesystem in high quality?


Best regards,
Torsten.


> Hi,
>
> I load a JPEG image using Tk::JPEG::Lite and i want to turn
> that image clockwise or counterclockwise by 90 degree.
>
> What would be the best way to do that?
>
> Is there some built-in function for that?
>
> Or do i need to use get() and put()?
>
> Can i get the data() of the image into a string and do
> the conversion faster there?
>
>
> Thanks for hints,
> Torsten.


Slaven Rezic

2004-10-21, 8:56 pm

Torsten Mohr <tmohr@s.netic.de> writes:

> Hi,
>
> thanks for the hints. I was a bit unprecise, i wrote
> a script to view the pics that i took with my digital
> camera, so i want to turn them permanently, save them
> back to disk.
>
> I first used jpegtopnm | pnmrotate | pnmtojpeg but
> went on to use GD, as it is more portable. But the
> qualtiy does not look good, though i chose a quality
> of 90 and the file size increases.
>
> Has anybody got a solution to turn the picture in the
> filesystem in high quality?
>


Image::Magick is slow, but the results are perfect.

Regards,
Slaven

--
Slaven Rezic - slaven <at> rezic <dot> de

tktimex - project time manager
http://sourceforge.net/projects/ptktools/
Martin Herrmann

2004-10-22, 3:56 am

Torsten Mohr <tmohr@s.netic.de> wrote in message news:<cl8s3k$e65$1@schleim.qwe.de>...
> Hi,
>
> thanks for the hints. I was a bit unprecise, i wrote
> a script to view the pics that i took with my digital
> camera, so i want to turn them permanently, save them
> back to disk.
>
> I first used jpegtopnm | pnmrotate | pnmtojpeg but
> went on to use GD, as it is more portable. But the
> qualtiy does not look good, though i chose a quality
> of 90 and the file size increases.
>
> Has anybody got a solution to turn the picture in the
> filesystem in high quality?


Use jpegtran (http://sylvana.net/jpegcrop/), which rotates JPEGs in a
lossless way - you won't get a better quality. :)

Regards
Martin

BTW.: If you look for a perl/Tk program to view and organize pictures
click here: http://mapivi.de.vu
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com