Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Graphics Software Linux

Graphics Tricks from the Command Line 68

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."
This discussion has been archived. No new comments can be posted.

Graphics Tricks from the Command Line

Comments Filter:
  • Useful... (Score:3, Insightful)

    by Kiriwas ( 627289 ) on Thursday July 17, 2003 @11:50AM (#6461754) Homepage
    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.
    • Re:Useful... (Score:2, Informative)

      by GigsVT ( 208848 )
      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.
    • Re:Useful... (Score:3, Informative)

      by JimDabell ( 42870 )

      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:

  • Gallery (Score:4, Informative)

    by L. VeGas ( 580015 ) on Thursday July 17, 2003 @11:53AM (#6461783) Homepage Journal
    ImageMagick is used quite a bit with online photo galleries. Here [sourceforge.net] is one of the most popular.
    • Re:Gallery (Score:5, Informative)

      by crisco ( 4669 ) on Thursday July 17, 2003 @12:40PM (#6462340) Homepage
      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 [sourceforge.net], another set of opensource image manipulation tools that deserve a little pimping along with ImageMagick.
  • by martin ( 1336 )
    and this differs from XV how - apart from maybe an API..
    • Re:XV (Score:3, Insightful)

      by ivan256 ( 17499 ) *
      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?
      • Well, for starters 'xv' is not free software and you have to purchase a license for non-commercial use,

        Duh. I meant you have to purchase a licencs fo commercial use. It's 'free as in beer' for non-commercial use.
    • It's free software, and therefore, it comes with my system (Debian) while XV doesn't. I can use it for my commercial website, or sell someone a system using it (a commercial transaction) without worrying about license fees. And it's been updated more recently than 1988! :)

      Oh, and it has that API and a library that third-party apps use directly, so having XV on my system would involve a lot of redundancy, while having ImageMagick just means a small app that uses the already-installed library.
  • I Love Image Magick! (Score:5, Interesting)

    by szyzyg ( 7313 ) on Thursday July 17, 2003 @12:07PM (#6461949)
    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.
  • Wonderful program (Score:5, Interesting)

    by digerata ( 516939 ) * on Thursday July 17, 2003 @12:14PM (#6462030) Homepage
    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 [handmadesw.com].

    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.

    • Re:Wonderful program (Score:2, Informative)

      by Tolchz ( 19162 )
      You can install the libraries yourself. ./configure --prefix=/home/myusername/magicklibs/

      Then specify the location when you compiler ImageMagick.
    • Most distros of linux come with IM as part of their main / stable distros. I've used it with Gentoo and debian via apt and emerge respectively, no problems. Redhat and Mandrake have it too! The windows version comes precompiled / statically linked, so that's no big deal. What were you using?
      • ...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.
        • 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.
    • "It is the most god awful spaghetti mess of all time when it comes to its dependancies."

      Unless, of course, you're running it on FreeBSD...
  • At work we often work with multipage tiff images (~650MB) that we need to pull individual images out of. We currently have a poorly implemented hack to do it, but I am looking to find a better library to do this. I was wondering if anyone has a decent java library that they know about.

    Ideally something that works with msjava (java 1.1). I know in java 1.4 there is jai, but atleast immediately that does not seem to be a very understandable api.

    Anyways, we'll see if this gets any hits.
  • It's great! (Score:2, Interesting)

    by wizs ( 532010 )
    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.

  • Can anyone compare IM to the pbm tools?
    • Re:netpbm tools? (Score:4, Informative)

      by Alan Shutko ( 5101 ) on Thursday July 17, 2003 @02:38PM (#6463693) Homepage
      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.
      • Re:netpbm tools? (Score:2, Interesting)

        by Unordained ( 262962 )
        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
        • I too tried to use IM for large scale commercial tiff and pdf work and found it lacking quite a bit in the area of speed :( And even loading a few moderate sized tiffs -> mp tiffs created gb sized temp files before they were reworked. Windows shareware could do the conversions easily 100x faster. We really need _good_ tiff and pdf software
      • What in the world is that 150MB JPG a picture *of?*
  • I used to this to change the hue of a load of pictures.

    I broke a picture of a map down into all the edges (roads) and then changed the images into various different hues.

    Now in a web page, you can see the roads change colour :)

  • I have a three head desktop and I needed some cool backgrounds. Unfortunately, the desktop is a single large canvas and not three smaller ones. I have a small script that grabs 3 random images from my backgrounds directory (mostly images from Digital Blasphemy) and stitches them together to form a single large background image.

    -sirket
  • I have been trying to automate some tasks here where the end results are graphs.
    The problem is that for Joe Nerd, the output of a scripted graph is "good enough" - I use GD for a lot of things and it looks fine and is fast enough to be generated on the fly.

    But my current need is to get graphs that look really good so that they can be used on a brochure type site, but can be updated frequently with the most recent market data (not updated in real time, every time the page is loaded - but updated by a script
    • If you have access to a Macintosh, or can squeeze out the budget for one, consider Keynote [apple.com], Apple's fancy presentation program.

      The files are in XML, so they would be a snap to generate them through scripts, and the display engine produces stunningly beautiful graphs.

      The graphs are so much prettier than Excel's it isn't even funny.

      If you play with it at an Apple Store, I think you'd get sold on it pretty quick.

      Hope that helps.

      D
    • You can automate Excel (and most other office apps) quite easily.

      Here's an example JScript script that creates a graph:

      var excel = new ActiveXObject ("Excel.Application");
      var book = excel.Workbooks.Add ();
      var sheet = excel.Worksheets (1);

      sheet.Range ("A1") = "foo";
      sheet.Range ("B1") = "bar";
      sheet.Range ("C1") = "goo";

      sheet.Range ("A2") = "1";
      sheet.Range ("B2") = "2";
      sheet.Range ("C2") = "3";

      var chart = sheet.ChartObjects.Add (100, 100, 200, 200).Chart;
      chart.ChartWizard (
      sheet.Range ("A1:C2"), // sour
      • Interesting! Thanks.

        I have done that in the past, but for whatever reason (stupidity on my part?), I haven't seen the Export functionality. Very useful.

        I will have to play with it to see about font size, weight, and positioning - but that looks like that would be quite nice.

        Thanks again.
  • Life saver! (Score:4, Interesting)

    by unfortunateson ( 527551 ) on Thursday July 17, 2003 @03:49PM (#6464497) Journal
    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.
  • PIL (Score:3, Interesting)

    by SeanAhern ( 25764 ) on Thursday July 17, 2003 @04:45PM (#6465128) Journal
    For those of you who use python [python.org], you might want to check out the Python Imaging Library [pythonware.com], 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 [pythonware.com] for some examples of what you can do.
  • Linux?? (Score:3, Interesting)

    by Jon Peterson ( 1443 ) <jon@@@snowdrift...org> on Thursday July 17, 2003 @06:13PM (#6465951) Homepage
    "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.

    • Re:Linux?? (Score:2, Informative)

      by Mikal ( 22767 )
      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.
  • by markjugg ( 21992 ) * <<mark> <at> <summersault.com>> on Thursday July 17, 2003 @09:07PM (#6467141) Homepage
    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

  • Say I give you two images where a portion of one on the edge is identical to a portion of the other on the opposite edge. I want to stitch these together to get one big image which seemlessly overlaps the two?

    How would you go about this?
  • I'm a big fan of ImageMagick, use it mostyly on Windows and haven't encountered any install problem some earlier post related, if you know how to press a "next" button that's well enough...

    Now one thing I've been looking for is something to let me read RAW (headerless) CCIT G.4 (fax-type encoding),ImageMagick doesn't support it and the few free tools I found didn't work quite well. Anybody got recommendations ?
  • Could this utility be used to convert gif imageds to png? I understand this is very difficult (since Slashdot still uses gif images), but hopefully, someday there will be a way to convert gifs to png format.
  • I've used it quite a bit, seems to be a bug in colour conversion though (at least in version 5.5.4).

    I found that it has problems converting an image to 256 color. It seems to mess up conversion of pixels with alpha transparency. The fix I found was to convert to gif format, then back to png (which automatically converts to 256 colour).

    This may be fixed in later versions though.
  • What about the GIMP? (Score:3, Interesting)

    by Ed Avis ( 5917 ) <ed@membled.com> on Sunday July 20, 2003 @07:52AM (#6483443) Homepage
    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?
  • From the ImageMagick site:

    ImageMagick is quite portable, and compiles under almost every general purpose operating system that runs on 32-bit or 64-bit CPUs. ImageMagick is available for virtually any Unix or Unix-like system, including Linux. It also runs under Windows '95 and later ('95, '98, ME, NT 4.0, 2000, and XP), Macintosh (MacOS 9 and 10), VMS, and OS/2.

    Once again, remember that freely available software, and software that comes with the source code, is NOT a Linux-specific phenomenon. In fact

We are each entitled to our own opinion, but no one is entitled to his own facts. -- Patrick Moynihan

Working...