LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-26-2011, 03:29 PM   #1
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
imagemagick with for loop on the commandline does not work like expected


Hello,

I have images in jpg format
Code:
CIMG0100.jpg
...
...
CIMG0131.jpg
consecutively. I used imagemagick to convert the files to gif with the following command
Code:
for i in {100..131}; do convert CIMG0$i.jpg CIMG0$i.gif; done # works
This worked like expected, but when afterwards I wanted to scale the images
Code:
for i in {100..131}; do convert -scale 25% CIMG00$i.gif CIMG00$i_scaled.gif; done # works not
it seems the system is working for about half a minute, but I get no output. The single command
Code:
convert -scale 25% CIMG100.gif CIMG100_scaled.gif # works
works as expected and gives me a scaled image.

Can anybody explain this behaviour? What does the convert command do in the second case? is the for-loop wrong?

Markus

Last edited by markush; 05-26-2011 at 03:37 PM. Reason: typo
 
Old 05-26-2011, 04:05 PM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Hi Markus,

this a problem with the expansion mechanism in bash. Try this:
Code:
for i in {100..131}; do convert -scale 25% CIMG00${i}.gif CIMG00${i}_scaled.gif; done
The first pair of braces is not needed but apparently bash tries to expand the variable
$i_scaled
in the second case.

Last edited by crts; 05-26-2011 at 04:07 PM.
 
1 members found this post helpful.
Old 05-26-2011, 04:24 PM   #3
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by crts View Post
... apparently bash tries to expand the variable $i_scaled in the second case.
thanks very much for the answer, now I've got it working.

Markus
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash loop not working as expected... replica9000 Linux - Software 10 04-24-2011 09:08 AM
LXer: ImageMagick from the Linux commandline LXer Syndicated Linux News 0 01-10-2009 08:50 AM
commandline mail does not seem to work okos Linux - Newbie 2 03-12-2008 07:43 PM
Trying to get GD or ImageMagick to work jwashburn Fedora 6 01-19-2007 01:52 PM
C: "or"(||) not functioning as expected in while loop mlaich Programming 4 12-04-2005 02:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration