Slashdot Mirror


Graphics Tricks from the Command Line

An anonymous reader writes "There's nothing quite like command-line tools for handling large batches of tasks, and image manipulations are no exception. Web developers and administrators will appreciate the ability to handle large numbers of files easily, either at the command line or in scripts. This article presents the ImageMagick suite, a Linux toolkit for sizing, rotating, converting, and otherwise manipulating images, in a huge number of formats, whether one or a hundred at a time."

21 of 68 comments (clear)

  1. Useful... by Kiriwas · · Score: 3, Insightful

    This seems like it could be useful for easy and fast (not always smart) integration into Web Applications. Its far easier to make a call to a command line image manipulation software than to call a library and do all the work yourself. Though I suppose with calling an application for the web, there may be security problems.

    1. Re:Useful... by GigsVT · · Score: 2, Informative

      I use it with a reverse proxy system. My web app on the internet facing server runs a PHP script that makes a HTTP request to an internal host that does the image processing.

      Done this way, it mitigates most security risks. I still scrub the data that can be influenced by the user, just in case.

      --
      I've had enough abrasive sigs. Kittens are cute and fuzzy.
    2. Re:Useful... by JimDabell · · Score: 2, Informative

      Its far easier to make a call to a command line image manipulation software than to call a library and do all the work yourself.

      Not particularly. For instance, with PHP:

  2. Gallery by L.+VeGas · · Score: 4, Informative

    ImageMagick is used quite a bit with online photo galleries. Here is one of the most popular.

    1. Re:Gallery by crisco · · Score: 4, Informative

      While it's true that ImageMagick is used quite often for online photo galleries and that Gallery is very popular, Gallery doesn't use ImageMagick (except for the forthcoming v2.0). Instead, it uses NetPBM, another set of opensource image manipulation tools that deserve a little pimping along with ImageMagick.

      --

      Bleh!

    2. Re:Gallery by L.+VeGas · · Score: 4, Informative

      Not true, but an understandable mistake.

      The latest version of Gallery (1.3.4) can and does use ImageMagick as well as NetPBM. I know many that have it running on their sites. It's just that Gallery's documentation is poor and rarely updated.

  3. I Love Image Magick! by szyzyg · · Score: 4, Interesting

    I used to use it a lot back when I was doing astronomy, I used to make movies and I wrote a load of scripts for IM which basically worked on directories full of jpegs to do crossfades, motion blur, and all sorts of other effects. Some of these movies of asteroids and comets still make it onto the occasional TV slot. The originals were rendered in POV ray, but IM was more important since it was essential for editing and compositing.
    It still runs today producing the map of asteroids (http://szyzyg.arm.ac.uk/~spm/), even though I've moved on a long time ago.
    For a while I even used ImageMagick as the core for a webcam motion detection program - rescale, blur, edge-detect, subtract differences and then count the total intensity of the output image - it worked pretty well, although it was a little slow.

    I think I've created more art with ImageMagick than I've done with the Gimp.

  4. Wonderful program by digerata · · Score: 4, Interesting
    I've used ImageMagick for a few years now, mostly for image processing on the backend of web application. It is great as far as the shear number of file formats it supports. I haven't seen any other 'free' application out there that does what ImageMagick does. Its speed is okay compared to commercial equivalents such as Image Alchemy.

    But the downfall of Image Magick is the installation. It is the most god awful spaghetti mess of all time when it comes to its dependancies. You see, what they don't tell you right off the bat is ImageMagick doesn't actually work with the file formats internally. AFAIK, it relies on all of the format specific libraries out there. If your application is hosted by a virtual hosting provider, good luck getting all that installed.

    Once it *is* installed, however, IM rocks.

    --

    1;
    1. Re:Wonderful program by Tolchz · · Score: 2, Informative

      You can install the libraries yourself. ./configure --prefix=/home/myusername/magicklibs/

      Then specify the location when you compiler ImageMagick.

  5. Re:XV by ivan256 · · Score: 2, Insightful

    Well, for starters 'xv' is not free software and you have to purchase a license for non-commercial use, while ImageMagick is distributed under a BSD style license...

    Do you have some code to change now?

  6. It's great! by wizs · · Score: 2, Interesting
    IMHO, it is great that image processing software provides a set of command-line programs. It is easy to extend the functionalities of the software by writing some scripts that utilize those command-line programs. I did write some perl scripts that combine some command-line programs of ImageMagick. These scripts help me to organize a lot of images taken by DC. They do great jobs.

    I also expect some commercial image procssing software (e.g., Adobe photoshop) may export some command-line programs.

  7. Re:netpbm tools? by Alan+Shutko · · Score: 3, Informative

    ImageMagick has all conversion type stuff in one "convert" program, so you don't have to pipe stuff between fifteen programs to get things done.

    OTOH, ImageMagick loads the entire file into memory to do its work, so on really big files you are better off shipping it through the pipe. (I've got a 150MB JPG around here that chokes convert, but pipes through netpbm great.)

    I like to have both on my machine.

  8. Life saver! by unfortunateson · · Score: 3, Interesting

    Imagemagick made me look like a miracle worker.
    10,000 1.5MB bitmaps had to be delivered to the Food and Drug Administration in their original format and resolution (they needed to see things exactly as they were reviewed in a drug safety study), but wanted a visual 'menu' of the images, by patient over time.

    Using the index of the images, I was able to create a labeled page-per-patient visual menu in PDF (FDA's preferred format -- but it would be a 3-character change to make it anything else). Using other tools, the same index was munged into a CSV file that was applied as hyperlinks atop the PDF menu (non-Open-Source tool, but I might have been able to find an open-source one).

    In one day, the entire set of 15GB of data could be processed. In fact, putting it on a tape took longer than the image assembly.

    --
    Design for Use, not Construction!
  9. Re:Not hard at all to install by Thornae · · Score: 2, Insightful

    ...and, of course, FreeBSD has it in the ports tree. You would be amazed at the number of graphics (and other) ports that pull in the latest version of ImageMagick as a dependancy.

    Mind you, NetPBM isn't under-represented, either.

    --
    |>
    Here be Dragons
  10. PIL by SeanAhern · · Score: 2, Interesting

    For those of you who use python, you might want to check out the Python Imaging Library, or PIL for short.

    After using many, many different tools for this type of thing (including IM, netPBM, GD, and my own tools), PIL has by far become my favorite for image processing.

    Check out this simple tutorial for some examples of what you can do.

  11. Re:Not hard at all to install by dave_f1m · · Score: 2, Insightful

    And of course, Windows. I wrote some stuff for a photographer with Perl,Tk, and ImageMagick, and it works fine on her W98 machine. Well, I would prefer something nicer than Tk, but it seemed like that was the best choice for cross platform with Perl.

  12. Linux?? by Jon+Peterson · · Score: 2, Interesting

    "This article presents the ImageMagick suite, a Linux toolkit for sizing..."

    WTF has this got to do with Linux? AFAIK IM pre-dates any kind of wide-spread use of Linux. IM compiles on most unixes and is available for mac, win32, vms and more. It has nothing to do with Linux.

    Sigh.

    --
    ----- .sig: file not found
    1. Re:Linux?? by Mikal · · Score: 2, Informative

      I think you'll find that the article is written that way because it is taylored for the IBM DeveloperWorks Linux site. It's not a comment on the Linuxness of IM.

  13. Re:netpbm tools? by Unordained · · Score: 2, Interesting

    on a web-app project i got to play with in mid-devel ... image-magick was used to convert from TIFF to GIF (i think) output. the problem was speed -- it loaded the entire image into memory in its own internal format. the problem is that the TIFF files were enormous, but they were black/white scans of documents. the final gif was also low-color, and scaled down ... but in-between, it was converting to full 24-bit color (with alpha?) and other overhead.

    in the end, (after we had left and done our part of the job) someone else (team lead) changed the code to a customized piece that resized the file as it streamed through, directly from TIFF to whatever output format was being used ... MUCH MUCH FASTER.

    image magick is neat -- lots of formats. but it's a lot of overhead in situations where you need speed. specialized tools (format_a2format_b) are of great help at that point.

  14. create multi-page PDFs by markjugg · · Score: 3, Informative
    ImageMagick can also be used to convert several image formats into a multi-page PDF. I used this just recently:

    convert -adjoin photos*.jpg one_big.pdf

  15. What about the GIMP? by Ed+Avis · · Score: 2, Interesting

    ImageMagick is great but I always feel that the same functionality must already be present in the GIMP, and it seems rather wasteful to have to learn two different tools to do the same job.

    The GIMP is scriptable with Scheme or with Perl or other languages... perhaps all it needs is a good set of command-line interfaces as well?

    --
    -- Ed Avis ed@membled.com