If we were converting just one file this might be:Ĭonvert 123.tif. This linux command enables us to strip off the extension from ‘123.tif’ and be left with ‘123’, to which we append a ‘.jpeg’ to tell ‘convert’ that we want the output to be a jpeg. converted-images/full/ and names the file using the ‘basename’ command. (The second is an embedded thumbnail.) It puts the output in the directory at. The $file ($$file above in the Makefile) has a after it because we only want the first image embedded in the TIFF file. This uses imagemagick’s ‘convert’ utility to convert one of the TIFF files, say 123.tif, to a jpeg. What this does to begin with is to go into the output directory (from the renaming of files above), and using a standard bash for loop, takes each TIFF file and does:Ĭonvert $file. medium/$$file Ĭonvert -scale 250 $$file. tif`.jpg done Įcho "Doing large / medium / small / thumbs / tiny" įor file in *.jpg do echo "Doing $$file" Ĭonvert -scale 1000 $$file. To do monotonous repetitive things like this it is really quite easy.īecause I thought I might run this command many times, I created a Makefile with a ‘resizeImages’ target.įor file in *.tif do convert $$file. To do much more difficult things does take a bit of trial and error but really rewards study. It can do incredibly complicated things, but to do simple things like scaling images, cropping them, making montages, etc., is all fairly easy. My tool of choice when doing this is Imagemagick which is cross platform and incredibly powerful. Over the years I’ve done lots of image processing, cropping, resizing, rotating, extracting metadata, etc. There are a lot of other ways one could do this, in bash and using other technologies, but you use the hammer you happen to have to hand. It also moved a copy of the input file out of the way into a ‘processed’ directory just to note that it had been processed. What this did was go through the CSV and if there was both an old name (column A) and a new name (column B) it copied the file to a new output directory. Mv "$INPUT_DIR/$OLD_NAME" "$INPUT_DIR/processed/$OLD_NAME" # continue only if old file actually existsĬp -vf "$INPUT_DIR/$OLD_NAME" "$OUTPUT_DIR/$NEW_NAME" #output message if $OLD_NAME doesn't exist The script I wrote to rename the files was:įor CSV_LINE in "$CSV_LINE" | grep -o '^"*"' | sed 's/"//g'`$EXT That is it looked something like: Image File Name They provided huge TIFF files of manuscripts of Wycliffite Bibles and he had a spreadsheet with column A being a filename (without extension) and column B being the image ID in the website he is building for the project. A colleague in a different section (Software Solutions) of IT Services asked if I could help renaming and processing some images provided by the Bodleian Library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |