Results 1 to 5 of 5

Thread: shell script for utilizing imagemagiq to turn images into grey

  1. #1

    Default shell script for utilizing imagemagiq to turn images into grey

    hello dear opensuse-fans


    how to view photos and to rapidly change the major categories

    i have several hundred images (photographs) taht i want to view on opensuse linux version 13.1


    i want to view the images - and of while doing so i want to turn the colored images into b/w

    Question; which is the best - ie. the quickest way to do so.

    note; i have installed the following thigns on my opensuse 13.1:

    - gimp the great grahical tool
    - digicam - the great tool to view images and pictures
    - Gwenview Version 4.11.4 on KDE 4.11.5


    so again here the question: which tool allowes to view the color(ed) image and to turn it - on the fly - in to black and white?

    BTW: can i tell linux to swith the colors - in general - to black and white? is this doable...


    looks like we could write a small shell script, utilizing imagemagick.- maybe like this:

    Code:
    for i in *jpg ; do mogrify -colorspace Gray "$i" ; done
    this is just a quick hack. i haven't tried it. also, it's not interactive and simply changes all jpg's to grayscale, even if they already are grayscale.
    btw we need more information about imagemagick.


    see the results:

    Code:
    martin@linux-70ce:~/Bilder> 
    martin@linux-70ce:~/Bilder> for i in *jpg ; do mogrify -colorspace Gray "$i" ; done
    mogrify: unable to open image `*jpg': Datei oder Verzeichnis nicht gefunden @ error/blob.c/OpenBlob/2643.
    mogrify: no decode delegate for this image format `*jpg' @ error/constitute.c/ReadImage/552.
    martin@linux-70ce:~/Bilder>
    what can i do!?
    dilbert ;-)
    Wordpress-development - a Toolset: wpgear.org

  2. #2
    Join Date
    Jun 2008
    Location
    West Yorkshire, UK
    Posts
    3,450

    Default Re: shell script for utilizing imagemagiq to turn images into grey

    Code:
    man convert
    offers
    Code:
    convert input-image -greyscale method [output-image]

  3. #3

    Default Re: shell script for utilizing imagemagiq to turn images into grey

    hello dear john


    many thanks


    Quote Originally Posted by john_hudson View Post
    Code:
    man convert
    offers
    Code:
    convert input-image -greyscale method [output-image]
    should i run this code in the folder of the images?

    Code:
    mogrify: unable to open image `*jpg': Datei oder Verzeichnis nicht gefunden @ error/blob.c/OpenBlob/2643.
    mogrify: no decode delegate for this image format `*jpg' @ error/constitute.c/ReadImage/552.
    martin@linux-70ce:~/Bilder> convert input-image -greyscale method [output-image]
    convert: unable to open image `input-image': Datei oder Verzeichnis nicht gefunden @ error/blob.c/OpenBlob/2643.
    convert: no decode delegate for this image format `input-image' @ error/constitute.c/ReadImage/552.
    convert: unrecognized option `-greyscale' @ error/convert.c/ConvertImageCommand/1675.
    i think i have to re-order the code line?
    dilbert ;-)
    Wordpress-development - a Toolset: wpgear.org

  4. #4
    Join Date
    Sep 2014
    Location
    Portugal
    Posts
    121

    Default Re: shell script for utilizing imagemagiq to turn images into grey

    On 09/14/2014 09:06 PM, dilbertone wrote:
    >
    > hello dear opensuse-fans
    >
    >
    > how to view photos and to rapidly change the major categories
    >
    > i have several hundred images (photographs) taht i want to view on
    > opensuse linux version 13.1
    >
    >
    > i want to view the images - and of while doing so i want to turn the
    > colored images into b/w
    >
    > Question; which is the best - ie. the quickest way to do so.
    >
    > note; i have installed the following thigns on my opensuse 13.1:
    >
    > - gimp the great grahical tool
    > - digicam - the great tool to view images and pictures
    > - Gwenview Version 4.11.4 on KDE 4.11.5
    >
    >
    > so again here the question: which tool allowes to view the color(ed)
    > image and to turn it - on the fly - in to black and white?
    >
    > BTW: can i tell linux to swith the colors - in general - to black and
    > white? is this doable...
    >
    >
    > looks like we could write a small shell script, utilizing imagemagick.-
    > maybe like this:
    >
    >
    > Code:
    > --------------------
    >
    > for i in *jpg ; do mogrify -colorspace Gray "$i" ; done
    >
    > --------------------
    >
    >
    > this is just a quick hack. i haven't tried it. also, it's not
    > interactive and simply changes all jpg's to grayscale, even if they
    > already are grayscale.
    > btw we need more information about imagemagick.
    >
    >
    > see the results:
    >
    >
    > Code:
    > --------------------
    > martin@linux-70ce:~/Bilder>
    > martin@linux-70ce:~/Bilder> for i in *jpg ; do mogrify -colorspace Gray "$i" ; done
    > mogrify: unable to open image `*jpg': Datei oder Verzeichnis nicht gefunden @ error/blob.c/OpenBlob/2643.
    > mogrify: no decode delegate for this image format `*jpg' @ error/constitute.c/ReadImage/552.
    > martin@linux-70ce:~/Bilder>
    >
    > --------------------
    >
    >
    > what can i do!?
    >
    >

    You'll have to run the script inside the folder, or you can add some
    lines to give you some options, and if you place the file in the Bin
    folder (in your home), you can access it in a terminal....or make a
    application link.
    make a chmod a+x to the file

    read -p "Enter the image folder to convert: > " -i "$HOME/" -e c
    path="$c"
    for i in "$c"/*jpg ; do mogrify -colorspace Gray "$i" ; done

    this is a rough example....


    --
    openSuSe 13.1

  5. #5

    Default Re: shell script for utilizing imagemagiq to turn images into grey

    Yes, you should run your for-loop inside the directory where your jpg resides. I also suggest to use *.jpg so you are sure that your code is for files ending in .jpg. If there are several hundreds pictures then find might be faster, if speed matters in your case.

    Code:
    find /PATH/TO/DIRECTORY -name '*.jpg' -execdir 'YOUR MOGRIFY CODE HERE' {} +
    That does not require you to be inside the directory where your jpg files are when you run that code. The only thing you need to replace in that code is the /PATH/TO/DIRECTORY which is the directory where your jpg files are and 'YOUR MOGRIFY CODE HERE' which is the code to convert your jpg files, the rest is as is.
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

Posting Permissions

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