Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
G'day Everyone, It's been a while since I've posted here but I've run into a problem that no amount of Googling will resolve. I'm using Image Magick to add a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2010
    Location
    Sydney, Australia
    Posts
    68

    imagemagick from bash script...


    G'day Everyone,
    It's been a while since I've posted here but I've run into a problem that no amount of Googling will resolve.

    I'm using Image Magick to add a footer into JPG files and running this from the command line works every time without error however when I copy this into a bash script I get an error:
    convert: option requires an argument `-annotate' @ error/convert.c/ConvertImageCommand/660.

    Code:
    convert /mnt/sdcard/testimage.jpg -gravity South -chop 0x38  background black -fill white -splice 0x37 -pointsize 32 -annotate +0+2 test
    inside bash script:
    Code:
    #!/bin/bash
    convert /mnt/sdcard/testimage.jpg -gravity South -chop 0x38  background black -fill white -splice 0x37 -pointsize 32 -annotate +0+2 test
    Does anyone have any ideas?
    Last edited by r31griffo; 09-27-2011 at 02:13 PM. Reason: typo

  2. #2
    Just Joined!
    Join Date
    Jan 2010
    Location
    Sydney, Australia
    Posts
    68
    I'm not sure if it will help diagnose the problem, but I'm running Debian Lenny with Dash shell (tried Bash but no change)

  3. #3
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    At first glance...

    Don't you need a filename at the end?

    Don't you need a missing '-' before the background option?

    e.g.:
    Code:
    convert /mnt/sdcard/testimage.jpg -gravity South -chop 0x38 -background black -fill white -splice 0x37 -pointsize 32 -annotate +0+2 test /tmp/testimage2.jpg

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Jan 2010
    Location
    Sydney, Australia
    Posts
    68
    Quote Originally Posted by atreyu View Post
    At first glance...

    Don't you need a filename at the end?
    are the requirements different inside a script than outside? This works if not used inside the script.

    As far as I'm aware, becase the file is ammended (not appended) it only needs to be done at the start of the command...Please let me know if this is not accurate.

    Quote Originally Posted by atreyu View Post
    Don't you need a missing '-' before the background option?

    e.g.:
    Code:
    convert /mnt/sdcard/testimage.jpg -gravity South -chop 0x38 -background black -fill white -splice 0x37 -pointsize 32 -annotate +0+2 test /tmp/testimage2.jpg
    I'm not sure I get you...from what I see in my example there is a hyphen in it...do I need another before the colour? or do you mean a double - before background?.

    In the example given, this is to ammend a file, not append a file and from what I understand (I might be wrong, please tell me if I am) the ammended file only needs to be listed at the start of the command.

    I'm open to any ideas, please let me know and thank you for reading the response.

  6. #5
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    I guess we've got substantially different versions of ImageMagick (mine reports 6.0.7). The command as you posted it did not work on my system without an output filename, and it also complained about the background switch without a hyphen (your posted example does not show a hyphen before background on my computer anyway...). And no, it shouldn't be different whether called on the command line or via script - that is indeed weird.

    EDIT: do you have multiple versions of ImageMagick installed? maybe the script finds one version, and is found in another path when run in the shell...
    Last edited by atreyu; 09-27-2011 at 04:07 PM. Reason: multiple versions?

  7. #6
    Just Joined!
    Join Date
    Jan 2010
    Location
    Sydney, Australia
    Posts
    68
    atreyu,
    I just noticed your reply goes to /tmp ... I just realised I was writing this to NAND, not RAM. Thank you for demonstrating this to me...otherwise I could of had an issue in a couple of years time and not known why

  8. #7
    Just Joined!
    Join Date
    Jan 2010
    Location
    Sydney, Australia
    Posts
    68
    I'm running ImageMagick 6.6.0-4 (from Debian Squeeze repository), as far as I know there is only 1 version of it installed...I can only find 1 convert binary located at: /usr/bin/convert

    I'm not sure what you mean about the background switch missing a hyphen, there is one there.

    I've tried the example you posted from the command line and I got "test /tmp/testimage2.jpg" as the footer (without the quotation marks of course )

    Do you know of another way to ammend a picture with a footer? All examples on the web append the picture, the result is multiple footers if the command is run more than once...It took me a couple of hours to figure this one out.

  9. #8
    Just Joined!
    Join Date
    Jan 2011
    Location
    Fairfax, Virginia, USA
    Posts
    94
    r31griffo,
    I tried your example and I was able to reproduce your problem exactly. I managed to fix up the command and realized I did what Atreyu suggested. I'm pretty sure his suggestion works.

  10. #9
    Just Joined!
    Join Date
    Jul 2010
    Location
    New Mexico, USA
    Posts
    31
    I agree with atreyu regarding the hyphen missing preceding "background" in the original posting.

  11. #10
    Just Joined!
    Join Date
    Jan 2010
    Location
    Sydney, Australia
    Posts
    68
    Please accept my apologies, Atreyu was correct all along.
    There was a hyphen missing and putting the new filename after the text fixed all my problems...
    I had been working on this problem for so long and I was so tired that I don't think I was thinking straight anymore. When I looked at it again tonight with fresh eyes, Atreyu's post made a lot more sense to me.

    Anyway, thank you everyone who posted here I really do appreciate the help.

    Cheers,

    Griffo

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •