Sponsored Content
Top Forums Shell Programming and Scripting Bash for image resize using ImageMagick Post 302343530 by Imhotep1963 on Wednesday 12th of August 2009 06:10:20 PM
Old 08-12-2009
Question Bash for image resize using ImageMagick

Hi all,

I have a FreeNAS server hosting all of my images. The original images are high resolution. What I would like to do is 2 parts:

1. do a batch resize of all of the images so I have web-friendly version and print ready version
2. run a cron job to apply the bash to any "new" files

First I want to tackle the bash script. As far as I can tell, these are the things that I must take into account:

1. I have a directory structure that I want to duplicate and maintain
2. I want to keep the originals
3. I want a duplicate that is web-friendly
4. Original dir is "./pictures"
5. New dir is "./resized"
6. Script will live in the "/pictures" dir
7. Identify new images

I think that is it! Smilie

I know how to copy the structure but I don't think that Imagemagick will check recursively by itself. That is where I am stuck.

I'm relatively new to bash, but here is what I have so far:

Code:
#!/bin/bash

# find all directories, copy structure

find . -type d | cpio -pvdm ../resized

# creates the new image, move to new dir

for f in *.jpg;
do
    echo "Processing $f"
    convert -resize "50%"  \
        $f ./resized/$f
done

The copy of the image "$f ./resized/$f" will just be dumped into the root of "/resized". So I am stuck there too.

I'm also wondering about the logic for the next step of checking for new images, then running the convert part on that. Is there a command that will compare the dir and identify the new files?

I appreciate any help!

Thanks!
Smilie
 

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

imageMagick?

Hi I am planning to install ImageMagick on my server here. I have learned what I needed about Unix when I needed it..... but I have never installed anything before. I have downloaded the necessary file from imagemagick.org, and their installation instructions seem easy enough (only 2 or 3... (2 Replies)
Discussion started by: bob2003
2 Replies

2. UNIX for Advanced & Expert Users

Create an Ignite image on tape from Online IgniteUX image

Hi, (HP-UX 11.11) I need to create a tape image of an igniteUX image created on our igniteUX server. That is to say. I have a "Online" image of the igniteUX of the targeted system but I now need to copy it to a useable TAPE (igniteUX) image so i can build an other server from it that is not... (3 Replies)
Discussion started by: Andrek
3 Replies

3. UNIX and Linux Applications

looking for ImageMagick install package

i am struggling to find an error free, and complete install package for ImageMagick (with perl- "PerlMagick"). imagemagick.org not much help.... links for source, mirrors etc dont work. any pointers appreciated. linux server. (2 Replies)
Discussion started by: mickeymouse
2 Replies

4. Shell Programming and Scripting

Imagemagick File Padding Issue

Hello, I'm having a problem figuring out the syntax for padding 10-99. Everything else in the program works fine so I want to focus in on just this part of the code. Below is a snippet of the code that I am having problems with. I appreciate all the help I can get. Thank you. The script... (7 Replies)
Discussion started by: jsells20
7 Replies

5. Shell Programming and Scripting

Need a little help with my first shell script. Basic image resize script...

Hey everyone, just now joined because I didn't want to go onto Ubuntu forums and start asking about how to write shell scripts. Seems like this is a pretty active forum for exactly what I need. I'm trying to modify a shell script I found online, the end goal is to have it find all files in the... (9 Replies)
Discussion started by: mozzles
9 Replies
ImageMagick(1)						      General Commands Manual						    ImageMagick(1)

NAME
ImageMagick - is a free software suite for the creation, modification and display of bitmap images. SYNOPSIS
convert input-file [options] output-file OVERVIEW
ImageMagick(R), is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of for- mats (about 100) including GIF, JPEG, JPEG-2000, PNG, PDF, PhotoCD, TIFF, and DPX. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and B['e]zier curves. ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you can freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems. The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite programming language. Choose from these interfaces: MagickCore (C), MagickWand (C), ChMagick (Ch), Magick++ (C++), JMagick (Java), L-Magick (Lisp), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), PythonMagick (Python), RMagick (Ruby), or TclMagick (Tcl/TK). With a language interface, use ImageMagick to modify or create images automagically and dynamically. ImageMagick includes a number of command-line utilities for manipulating images. Most of you are probably accustom to editing images one at a time with a graphical user interface (GUI) with such programs as gimp or Photoshop. However, a GUI is not always convenient. Suppose you want to process an image dynamically from a web script or you want to apply the same operations to many images or repeat a specific opera- tion at different times to the same or different image. For these types of operations, the command-line image processing utility is appro- priate. In the paragraphs below, find a short description for each command-line tool.Cl ick on the program name to get details on the program usage and a list of comman d-line options that alters how the program performs. If you are just getting acq uainted with ImageMagick, start at the top of the list, the convert program, and work your way down. Also be sure to peruse Anthony Thyssen's tutorial on how to use ImageMagick utilities to convert, compose, or edit images from the command- line. convert convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. identify describes the format and characteristics of one or more image files. mogrify resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. Mogrify overwrites the original image file, whereas, convert writes to a different image file. composite overlaps one image over another. montage create a composite image by combining several separate images. The images are tiled on the composite image optionally adorned with a border, frame, image name, and more. compare mathematically and visually annotate the difference between an image and its reconstruction.. stream is a lightweight tool to stream one or more pixel components of the image or portion of the image to your choice of storage formats. It writes the pixel components as they are read from the input image a row at a time making stream desirable when working with large images or when you require raw pixel components. display displays an image or image sequence on any X server. animate animates an image sequence on any X server. import saves any visible window on an X server and outputs it as an image file. You can capture a single window, the entire screen, or any rectangular portion of the screen. conjure interprets and executes scripts written in the Magick Scripting Language (MSL). For more information about the ImageMagick, point your browser to file:///usr/share/doc/imagemagick/index.html or http://www.imagemag- ick.org/. SEE ALSO
convert(1), identify(1), composite(1), montage(1), compare(1), display(1), animate(1), import(1), conjure(1), quantize(5), miff(4) COPYRIGHT
Copyright (C) 1999-2012 ImageMagick Studio LLC. Additional copyrights and licenses apply to this software, see file:///usr/share/doc/imagemagick/www/license.html or http://www.imagemagick.org/script/license.php ImageMagick Date: 2009/01/10 01:00:00 ImageMagick(1)
All times are GMT -4. The time now is 07:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy