The second script makes it 300 pixels wide and calculates the proportional height. The first one shrinks the image to 128x128 pixels. You must be in the same directory as the picture files for both of these scripts. To use Script #2: python resizescript.py yourfilenamehere.jpg To use Script #1: python resizescript.py yourfilenamehere.jpg Ctrl+x to exit (say yes to save changes). Paste one of those blocks of code into the text editor. Now, how to do this through the terminal. Img = img.resize((basewidth,hsize), Image.ANTIALIAS) Hsize = int((float(img.size)*float(wpercent))) Print "cannot create thumbnail for '%s'" % infileĪnd another example where you only have to specify the width (as the width variable): Outfile = os.path.splitext(infile) + ".thumbnail" Those examples use just the standard library. Since Ubuntu ships with Python, you can also use a Python script to achieve this with a little more control over what happens - see this stackoverflow question for example scripts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |