PDA

View Full Version : [SCRIPT] Rotate (sharpen,...) images with a right-click



probono
04-15-2003, 01:14 AM
For Windows XP, there is a power tool that lets you rotate images by right-clicking. Now, there is this feature for Knoppix too. Simply run the following or put it in your knoppix.sh and then you can rotate images in Konqueror with a right-click.


#!/bin/bash

#################### OUTDATED, FOR NEW VERSION SEE BELOW ####################

# rotate images by right-clicking in Konqueror
# by probono
# This script is published under the GPL

mkdir -p ~/.kde/share/apps/konqueror/servicemenus

cat >> ~/.kde/share/apps/konqueror/servicemenus/rotate_ccw.desktop <<EOF
[Desktop Entry]
ServiceTypes=image/png,image/jpeg,image/gif
Actions=rotate_ccw

[Desktop Action rotate_ccw]
Name=Rotate counter-clockwise
Icon=rotate_ccw
Exec=/bin/sh -c "for file in %U; do mogrify -rotate 270 $file; done"
EOF

cat >> ~/.kde/share/apps/konqueror/servicemenus/rotate_cw.desktop <<EOF
[Desktop Entry]
ServiceTypes=image/png,image/jpeg,image/gif
Actions=rotate_cw

[Desktop Action rotate_cw]
Name=Rotate clockwise
Icon=rotate_cw
Exec=/bin/sh -c "for file in %U; do mogrify -rotate 90 $file; done"
EOF

probono
04-15-2003, 01:18 AM
Btw, this solution is done using imagemagick. You can also resize, rotate, sharpen, color reduce, or add special effects to an image or image sequence and save your completed work in the same or differing image format. Have a look at /usr/share/doc/imagemagick/html/ImageMagick.html in Knoppix.

For information on how to make the context menus, there is an excellent article on http://developer.kde.org/documentation/tutorials/dot/servicemenus.html

So, be creative!

Fabianx
04-15-2003, 12:49 PM
Btw, this solution is done using imagemagick. You can also resize, rotate, sharpen, color reduce, or add special effects to an image or image sequence and save your completed work in the same or differing image format. Have a look at /usr/share/doc/imagemagick/html/ImageMagick.html in Knoppix.

For information on how to make the context menus, there is an excellent article on http://developer.kde.org/documentation/tutorials/dot/servicemenus.html

So, be creative!

Thats a very cool script! I like it a lot.

I created a bug report and will try to get it in the next iso, if I find the time. (my todo list grows longer ;-) )

cu

Fabian

true1ever
04-15-2003, 03:52 PM
does this do a lossless jpg rotate?

regards,
Jim

probono
04-15-2003, 11:12 PM
I created a bug report and will try to get it in the next isoIf you want to include it in the ISO, you don't have to put the script on the CD, just copy the files it creates in ~/.kde/share/apps/konqueror/servicemenus/ to /usr/share/apps/konqueror/servicemenus.

probono
04-15-2003, 11:44 PM
does this do a lossless jpg rotate?the new version does, and it also preserves EXIF data:

#!/bin/bash

# Lossless JPG image rotation in the Konqueror context menu
# uses jpegtran which comes with Knoppix
#
# by probono
# GPL

mkdir -p ~/.kde/share/apps/konqueror/servicemenus

cat >> ~/.kde/share/apps/konqueror/servicemenus/rotate.desktop <<EOF
[Desktop Entry]
ServiceTypes=image/jpg,image/jpeg
Actions=rotatejpgCCW;rotatejpgCW;fliphor;flipver

[Desktop Action rotatejpgCCW]
Name=Rotate Counterclockwise
Icon=rotate_ccw
Exec=/bin/sh -c "for file in %U; do jpegtran -copy all -rotate 270 -outfile rotate \$file; mv rotate \$file; done"

[Desktop Action rotatejpgCW]
Name=Rotate Clockwise
Icon=rotate_cw
Exec=/bin/sh -c "for file in %U; do jpegtran -copy all -rotate 90 -outfile rotate \$file; mv rotate \$file; done"

[Desktop Action fliphor]
Name=Flip Horizontal
Exec=/bin/sh -c "for file in %U; do jpegtran -copy all -flip horizontal -outfile rotate \$file; mv rotate \$file; done"

[Desktop Action flipver]
Name=Flip Vertical
Exec=/bin/sh -c "for file in %U; do jpegtran -copy all -flip vertical -outfile rotate \$file; mv rotate \$file; done"
EOF
It is now no longer based on imagemagick, but now based on http://www.solidhosting.nl/~arends/kde/ " For losness rotating JPG images the script uses jpegtran. This program is provided by the Indepentent JPEG group in libjpeg."

Fabianx
04-26-2003, 10:45 PM
does this do a lossless jpg rotate?the new version does, and it also preserves EXIF data:

#!/bin/bash

# Lossless JPG image rotation in the Konqueror context menu
# uses jpegtran which comes with Knoppix
#
# by probono
# GPL

mkdir -p ~/.kde/share/apps/konqueror/servicemenus

cat >> ~/.kde/share/apps/konqueror/servicemenus/rotate.desktop <<EOF
[Desktop Entry]
ServiceTypes=image/jpg,image/jpeg
Actions=rotatejpgCCW;rotatejpgCW;fliphor;flipver

[Desktop Action rotatejpgCCW]
Name=Rotate Counterclockwise
Icon=rotate_ccw
Exec=/bin/sh -c "for file in %U; do jpegtran -copy all -rotate 270 -outfile rotate \$file; mv rotate \$file; done"

[Desktop Action rotatejpgCW]
Name=Rotate Clockwise
Icon=rotate_cw
Exec=/bin/sh -c "for file in %U; do jpegtran -copy all -rotate 90 -outfile rotate \$file; mv rotate \$file; done"

[Desktop Action fliphor]
Name=Flip Horizontal
Exec=/bin/sh -c "for file in %U; do jpegtran -copy all -flip horizontal -outfile rotate \$file; mv rotate \$file; done"

[Desktop Action flipver]
Name=Flip Vertical
Exec=/bin/sh -c "for file in %U; do jpegtran -copy all -flip vertical -outfile rotate \$file; mv rotate \$file; done"
EOF
It is now no longer based on imagemagick, but now based on http://www.solidhosting.nl/~arends/kde/ " For losness rotating JPG images the script uses jpegtran. This program is provided by the Indepentent JPEG group in libjpeg."

thx, both scripts will be added in next iso.

cu

Fabian