Jump to content

rezise a picture


jeanrev
 Share

Recommended Posts

You can always use the good ol cli way (as long as you know what the pixel size of the new pic is going to be)

 

Here's an example from a screenshot script from rcxau:

convert currentdesk.jpg -resize 200x150 currentdesk_thumb.jpg

make sure you have imagemagick installed. if not, as root

urpmi imagemagick

.

convert is very powerful and i wish i had discovered it sooner. i use it all the time to get pictures ready to go on my website and it's much faster at rotating images than going into gimp each time. the man page has a lot of good info, but to rotate/tilt an image, you can

convert -rotate 90 input.jpg output.jpg

(if you just want to rotate it, make input the same as output)

 

here's a good page of info: http://www-106.ibm.com/developerworks/libr...raf/?ca=dnt-428

Link to comment
Share on other sites

A Challenge for the CLI minded.

 

I want to recursively run through my photo directories and rotate any of the pictures I have that were taken sideways.

 

To do this I guess I need to key on sky or something and try and guess which way is up.

 

Any ideas????

Link to comment
Share on other sites

I want to recursively run through my photo directories and rotate any of the pictures I have that were taken sideways.

 

jpegtran - lossless transformation of JPEG files

 

 

To do this I guess I need to key on sky or something and try and guess which way is up.  

 

How many photos do you have? More than 1000?

 

If you don't have that many you could rotate all of them with jpegtran and than delete incorect ones with gqview (disable confirm delete).

Link to comment
Share on other sites

Well over a thousand

Probably over 10,000

I know Ive taken 9900 since I got my 'new' digital camera and that doesn't include older ones or photoCd's from my SLR.

 

Ultimately I want to put them on a DVD but everytiome I do this (or any other safeguard) I end up altering the live ones for rotation etc. and a certain amount of duplication

Link to comment
Share on other sites

A Challenge for the CLI minded.

 

I want to recursively run through my photo directories and rotate any of the pictures I have that were taken sideways.  

 

To do this I guess I need to key on sky or something and try and guess which way is up.  

 

Any ideas????

 

With a bit of bash magic.

 

identify can find out the size, bash can take the size and call on convert can do the rotating if needed.

 

man identify

man convert

man imagemagick

 

Hey guys, linux is pretty violent, we kill programs and bash things

 

James

Link to comment
Share on other sites

I need some sort of RGB algorithm to identify 'the sky'

Maybe some CLI tool or maybe advanced GIMP???

 

The point being thse pictures are taken by rotating the camera 90º so they are identified as being Landscape by their relative dimensions.

This needs some sort of pattern recognition to determine if they have 'the sky' on the left or right depending which way I rotated the camera and then I can rotate eith 90 or 270.

Link to comment
Share on other sites

This needs some sort of pattern recognition to determine if they have 'the sky' on the left or right depending which way I rotated the camera and then I can rotate eith 90 or 270.

 

This seems as something that camera should support (it should detect position)...

 

Do you always have a sky? Is sky always blue?

Link to comment
Share on other sites

This needs some sort of pattern recognition to determine if they have 'the sky' on the left or right depending which way I rotated the camera and then I can rotate eith 90 or 270.

 

This seems as something that camera should support (it should detect position)...(Even if it did its in the OTHER directory ...which I never copies over...I just take the jpg's)

 

Do you always have a sky? Is sky always blue?

 

90% of my pictures probably have a sky

If it has one its usually some shade of blue..... I rarely bother taking pictures of rain!

 

I head about some porn detection software that works on skin-tones once....its this sort of thing I was looking for.

Link to comment
Share on other sites

90% of my pictures probably have a sky

If it has one its usually some shade of blue..... I rarely bother taking pictures of rain!

 

You could test what part of an image is more blue. Try this (you need to have perl-GD RPM package installed):

 

whereissky.pl:

#! /usr/bin/env perl

$^W = 1; use strict; use GD;

my $true = 1;

my $false = 0;



my $image = new GD::Image($ARGV[0]);

my ($width,$height) = $image->getBounds();



$width = $width - ($width%2);

$height = $height - ($height%2);



print "$width x $heightn";



my ($x, $y);

my ($nw, $ne, $sw, $se) = (0, 0, 0, 0);



for ($y = 1; $y <= $height; $y++) {

for ($x = 1; $x <= $width; $x++) {

 my $index = $image->getPixel($x-1,$y-1);

 my ($r,$g,$b) = $image->rgb($index);



 if (($r > $b) or ($g > $b)) {

	 $b = 0;

 }

 if ($y > ($height / 2)) {

	 if($x > ($width / 2)) {

   $se += $b;

	 } else {

   $sw += $b;

	 }

 } else {

	 if($x > ($width / 2)) {

   $ne += $b;

	 } else {

   $nw+= $b;

	 }

 }

}

}





print "NW:$nw, NE:$ne, SW:$sw, SE:$sen";

my $up = $nw + $ne;

my $down = $sw + $se;

my $right = $ne + $se;

my $left = $nw + $sw;

print "Up: $up, Down: $down, Right: $right, Left: $leftnn";



sub max {

my $max = $up;

my $foo;

foreach $foo (@_) {

 $max = $foo if $max < $foo;

}

return $max;

}



my $max = max($up, $down, $left, $right);



print "Sky is ";

if ($up == $max) {

print "UP";

} elsif ($left == $max) {

print "on the LEFT";

} elsif ($right == $max) {

print "on the RIGHT";

} else {

print "DOWN";

}

print ".n";

 

Usage:

./whereissky.pl test.jpg

 

This script is VERY slow.

Link to comment
Share on other sites

Im impressed!

 

I'm going to give it a go.

I don't mind slow, anything has to be better than previewing 10,000 images by hand and then rotating them.

 

If I can do 90% of the rotated ones and only unrotate 1% of the ones really having blue on the outside then I'll be happy and have learned something!!!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...