Skip to content

Instantly share code, notes, and snippets.

@omsai
Created July 22, 2015 20:05
Show Gist options
  • Save omsai/bb23b993b937addafbd3 to your computer and use it in GitHub Desktop.
Save omsai/bb23b993b937addafbd3 to your computer and use it in GitHub Desktop.
Create center cropped thumbnail images
# Create thumbnails in another directory. Center resize and crop
# images to 150x150.
OBJDIR := ../tabs-square
IMG_SRC := $(wildcard *.jpg)
OBJS := $(addprefix $(OBJDIR)/,$(IMG_SRC))
$(OBJDIR)/%.jpg : %.jpg
convert \
$< \
-resize 150 \
-gravity center \
-crop 150x150+0+0 \
$@
all : $(OBJS)
$(OBJS) : | $(OBJDIR)
$(OBJDIR) :
mkdir $(OBJDIR)
.PHONY : clean
clean:
rm -f $(OBJDIR)/*.jpg
.PHONY : variables
variables:
@echo Sources: $(IMG_SRC)
@echo Target Directory: $(OBJDIR)
@echo Targets: $(OBJS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment