parsed.org

Tips by tag: image

Convert Imagesize and Output Html-Code by -Flo- on Feb 19, 2008 09:12 AM
I wrote a little Bash-script, that
  • Creates Thumbnails to a specific size
  • Converts original Images to a specific size
  • Creates Html-Code that will show the thumbnail and link to the image (Folders can be included)

Have fun with it:

#!/bin/bash

######################
# Set Variables
######################
ENDING=jpg;
IMG_SIZE=800;
THUMB_SIZE=150;
DIR=folder/folder/images/;
ID=/usr/bin/identify;

######################
# Create Thumbnail
######################
ls -1 *.$ENDING | grep -v thb |while read file;
do convert -thumbnail $THUMB_SIZEx$THUMB_SIZE "$file" "`basename _thb_"$file"`";
        echo "---> _thb_$file created";
done

######################
# Convert image
######################
ls -1 *.$ENDING | grep -v thb | while read file;
do convert -resize $IMG_SIZEx$IMG_SIZE "$file" "`basename "$file"`";
        echo "---> $file converted";
done

######################
# Output HTML-Code
######################
echo "######################";
echo "HTML-CODE:";
echo "######################";
ls -1 *.$ENDING | grep -v thb | while read file;
do
        h=$($ID -format \"%h\" "`basename _thb_"$file"`");
        w=$($ID -format \"%w\" "`basename _thb_"$file"`");
        echo "<a href=\""$DIR$file"\">";
        echo "<img alt=\"\" src=\""$DIR""`basename _thb_"$file"`"\" width=$w height=$h /></a>";
done
echo "######################";
bashconverthtmlimagethumbnail

You can use the convert program (included with imagemagick) to convert a LaTeX file to an image:

$ convert -density 144 -geometry 100% source.dvi dest.jpeg
commandsconvertdviimageimagemagicklatextextypesetting
Creating ICO Files by cygnus on Oct 20, 2005 01:44 PM

You can easily create an .ico file (e.g. a favicon.ico file for your website) with the ImageMagick convert program:

$ convert myicon.png favicon.ico
commandsconvertformaticoimageimagemagickwindows

To create a .ico file that can be used for the favicon.ico on webpages, you can use a nice little program called png2ico. There is no package for this in Debian or Ubuntu so you will need to compile it yourself. Compilation is very straightforward. You do need a libpng package. Most of the time it will be installed but if you see an error, just searching for that file will yield the package you need to get for your distribution.

The session below uses /usr/local/src for the compilation and installed to /usr/local/bin. It can be compiled anywhere and installed anywhere, but having it in your $PATH makes things easier:

$ cd /usr/local/src
$ wget http://www.winterdrache.de/freeware/png2ico/data/png2ico-src-2002-12-08.tar.gz
$ tar xvzf png2ico-src-2002-12-08.tar.gz
$ cd png2ico
$ make
$ sudo cp png2ico /usr/local/bin/
$ sudo cp doc/png2ico.1 /usr/local/man/man1/

Once compiled, upload your png images. They should be square; sizes 16x16 and 32x32 are suggested. To create the icon you would then call the following:

$ png2ico favicon.ico your_favicon16x16.png your_favicon32x32.png

Afterwards you will then have a favicon.ico file. You then place this in the webroot of your website add the following to <head></head> section of your webpages:

<link rel="shortcut icon" href="/favicon.ico" />

It's good form to include it, but most common browsers automatically look for an icon at that location.

commandsconvertfaviconiconimagepng2icoshellweb
Ranged Curl by xinu on Jan 15, 2005 02:29 PM

If you have a URL that you need to crawl and you know the range of numbers in the image, you can do something like this:

$ curl -O http://www.example.com/img/samples[00-99].jpg

That should (at least attempt to) fetch the images samples00.jpg through samples99.jpg. Enjoy!

If you're using more than one range, you'll want to build your filename or a path with the --create-dirs option. For example:

$ curl http://www.example.com/imgs[00-99]/samples[00-27].jpg --create-dirs -o "#1/#2.jpg"

Alternatively, you can just be ghetto and name the files like dirname_filename.jpg:

$ curl http://www.example.com/images[00-99]/samples[00-27].jpg -o "#1_#2.jpg"
commandscurlextrasimageshellurl
Resizing Images by xinu on Nov 03, 2005 08:00 AM

If you find yourself on a machine without the semi-ubiquitous ImageMagick packages, you might at least have pnmscale. Starting with a PNG file, you can do the following to resize it to 450 pixels wide:

$ pngtopnm < ./firefox-upgrade.png | pnmscale -x 450 | cjpeg -smoo 100 -qual 100 > firefox-upgrade.jpg
cjpegcommandsconvertfilterimageimagemagickpngpngtopnmpnmscaleresizescaleshell
RSS