• Image Magick (convert)

    From Michael F. Stemper@mstemper@gmail.com to alt.os.linux.ubuntu on Sun Feb 14 15:09:07 2021
    From Newsgroup: alt.os.linux.ubuntu

    I'm converting a web-scraped image from gif to png and cutting its
    bottom off (ouch!) at the same time. It seems that convert wants to
    be helpful and leaves me not only the part that I want, but the part
    that I don't want:

    user@host$ ll cur*
    -rw-rw-r-- 1 user user 158519 Feb 14 14:19 current.gif
    user@host$ convert current.gif -crop "1280x776!" current.png
    user@host$ ll cur*
    -rw-rw-r-- 1 user user 150582 Feb 14 14:57 current-0.png
    -rw-rw-r-- 1 user user 6115 Feb 14 14:57 current-1.png
    -rw-rw-r-- 1 user user 158519 Feb 14 14:19 current.gif
    user@host$

    For now, my script includes:
    rm current-1.png
    mv current-0.png current.png

    A bit less than elegant, but it works.

    What I would prefer would be if there was a way to tell convert that:
    a. I only want the 1280x776 part
    b. I'd like it to use the file name that I specified

    Spending some time at the imagemagick page left me none the wiser. There
    is so much there that I can't figure out what to look for.

    Any gurus out there who can lend a hand?

    --
    Michael F. Stemper
    Outside of a dog, a book is man's best friend.
    Inside of a dog, it's too dark to read.
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From mm@mm@mm.invalid to alt.os.linux.ubuntu on Sat Apr 3 09:03:03 2021
    From Newsgroup: alt.os.linux.ubuntu

    W dniu 14.02.2021 o 22:09, Michael F. Stemper pisze:

    user@host$ convert current.gif -crop "1280x776!" current.png

    For now, my script includes:
      rm current-1.png
      mv current-0.png current.png

    A bit less than elegant, but it works.

    What I would prefer would be if there was a way to tell convert that:
    a. I only want the 1280x776 part
    b. I'd like it to use the file name that I specified

    ----------several files in a directory-------------

    #!/bin/bash
    for P in *.gif
    do
    tmp=`basename $P .gif`
    cp $P $tmp
    convert $tmp -crop 1280x776+0+0 $tmp.png
    rm $tmp
    done

    ----------one file as argument---------------------

    #!/bin/bash
    tmp=`basename $1 .gif`
    cp $1 $tmp
    convert $tmp -crop 1280x776+0+0 $tmp.png
    rm $tmp

    --------------------------------------------------

    if it works?
    --- Synchronet 3.18a-Linux NewsLink 1.113