I'm trying to come up with a way of resizing images in a directory by half (longways). I have already used:

mogrify -resize 50% *

It does resize all the image in the file but width and length ways. I have a "pseudo" idea for:

for images in $picDir; do
    width = images.width()
    height images.height()
    convert -resize $height*$width/2 images

I am not sure if that is the correct way to go through a directory and I cannot find an efficent way to get the height and width of a specific file. I would like to also find a way to do this without using Imagemagick and something that is already pre instaled on a ubuntu machine. If that is possible!

  • Why not just resize by sqrt(2)/2 ~ 0.7071 (~71%). – Janis Mar 15 '15 at 15:01
  • I only want to cut then length in half not both hence why the original piece of code wont suffice. – Softey Mar 15 '15 at 15:12
  • Aha. But the -resize option requires a "geometry" as argument; I'd expect that something like 100%x50% (or vice versa) would then work. Have you tried that? – Janis Mar 15 '15 at 15:18
  • I have but that doesn't seem to change anything, strangley. – Softey Mar 15 '15 at 15:20
  • Works for me. Just tested it. – Janis Mar 15 '15 at 15:22

Depending on what you mean by resizing only the "length", try one of

mogrify -resize 50%x100% *

mogrify -resize 100%x50% *
  • I kept putting * instead of x. Silly mistake. Thank you – Softey Mar 15 '15 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.