[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cropping a large collection of .PNG screenshots



> for fn in *.png; do mv $fn $fn.bak; convert -crop whatever $fn.bak $fn; done
> 
> But that's assuming you know how to use 'convert -crop' 
> to do what you want, which I don't.
> .... 

# convert source -crop geometry target
#
#  geometry :  width x height + w_offset + h_offset
#
#  width x height specifies size of cropped target
#
#  offsets specify position in source
#  to begin cropping  

> Personally, I'd whip up a quick Pike script

# I think you also sprechen der python .... :-)
# 
# ---------------------------------------------

#!/usr/bin/env python

import subprocess as SP

fsource = 'houses.png'  # http://csphx.net/python/houses.png
ftarget = 'house.png'   # http://csphx.net/python/house.png

width   = 340
height  = 360

woffset = 325
hoffset = 360

geometry = '%sx%s+%s+%s' % ( width , height , woffset , hoffset )   

args     = [ "convert" , fsource , '-crop' , geometry , ftarget ]

process  = SP.Popen( args , shell = False )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona


Reply to: