[Nottingham] Image list

Martin martin at ml1.co.uk
Fri Dec 1 14:06:24 GMT 2006


Roger Light wrote:
> On 01/12/06, Robert Ross <rross at dmu.ac.uk> wrote:
> 
>> >so you might have
>> > to get ImageMagick and do...
>>
>> Hmmm, starting to look that way, but would be loath to do it.
> 
> Yet you're happy with having konqueror? :)
> 
> This is what I'd do. I've made it easy to improve so that we can talk
> about this all afternoon...
> 
> for pic in /var/www/images/*; do
>    size=$(ls -l /var/www/images/${pic} | awk '{print $5}')
>    width=$(identify ${pic} | awk '{print $3}' | sed -e 's/x.*//')
>    height=$(identify ${pic} | awk '{print $3}' | sed -e
> 's/.*x\([0-9]*\).*/\1/')
>    echo "${pic},${size},${width},${height}" >> list.csv
> done
> 
> That'll give you a csv file that you should be able to import into the
> database of your choice.

Ok... :-)

Weeeeeeeelllllllllllllllll...

I'd go and use "cut" as in:

identify * | cut -d ' ' -f 3,5

to get the dimensions and size.

So the alternate would be:

cd /var/www/images
for pic in * ; do
	echo -n "$pic "
	identify * | cut -d ' ' -f 3,5
done >>list.csv

to give a spaces delimited "csv" file in the pics directory.


You could pipe in a
sed -e 's/ /,/'
to bang in the commas.


Cheers,
Martin

-- 
----------------
Martin Lomas
martin at ml1.co.uk
----------------



More information about the Nottingham mailing list