using make to convert images to thumbs

Dave Johnson dave-gnhlug at davej.org
Sun Feb 26 12:50:01 EST 2006


Python writes:
> I have a client that laid out their images and thumbs into almost
> parallel directory structures.
> 	/img		/thumb
> 	  /x		  /img
> 	    /y		    /x
> 	      /*.jpg	      /y
> 			        /*.jpg
> 
> x and y are two digit directory names used to shorten the directory
> scans to retrieve files.  I thought I could use a Makefile to automate
> the creation of thumbs, but this pattern has me stumped.
> 
> I am going to just write a script to step through the source tree and
> check the corresponding time stamp unless someone offers a suggestion.
> (No they will not shuffle things around because they have lots of logic
> in place.)


here you go:


.DEFAULT: all
.DELETE_ON_ERROR:
.PHONY: all clean

IMAGES=$(wildcard img/*/*/*.jpg)
THUMBS=$(patsubst %,thumb/%,$(IMAGES))

all: $(THUMBS)

thumb/%: %
	@mkdir -p $(@D)
	convert $^ -scale 160x120 -quality 25 $@

clean:
	$(RM) $(THUMBS)




-- 
Dave




More information about the gnhlug-discuss mailing list