Skip to content

Commit

Permalink
Merge pull request #2937 from radarhere/fixes
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
hugovk committed Jan 6, 2018
2 parents 0ac6d6a + 696b381 commit 0504029
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
7 changes: 6 additions & 1 deletion src/PIL/IcnsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,18 @@ def _save(im, fp, filename):


if __name__ == '__main__':

if len(sys.argv) < 2:
print("Syntax: python IcnsImagePlugin.py [file]")
sys.exit()

imf = IcnsImageFile(open(sys.argv[1], 'rb'))
for size in imf.info['sizes']:
imf.size = size
imf.load()
im = imf.im
im.save('out-%s-%s-%s.png' % size)
im = Image.open(open(sys.argv[1], "rb"))
im = Image.open(sys.argv[1])
im.save("out.png")
if sys.platform == 'windows':
os.startfile("out.png")
6 changes: 5 additions & 1 deletion src/PIL/ImageShow.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,9 @@ def get_command_ex(self, file, title=None, **options):
register(XVViewer)

if __name__ == "__main__":
# usage: python ImageShow.py imagefile [title]

if len(sys.argv) < 2:
print("Syntax: python ImageShow.py imagefile [title]")
sys.exit()

print(show(Image.open(sys.argv[1]), *sys.argv[2:]))
14 changes: 5 additions & 9 deletions src/PIL/SpiderImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def isInt(f):
return 1
else:
return 0
except ValueError:
return 0
except OverflowError:
except (ValueError, OverflowError):
return 0

iforms = [1, 3, -11, -12, -21, -22]
Expand Down Expand Up @@ -286,7 +284,7 @@ def _save_spider(im, fp, filename):

if __name__ == "__main__":

if not sys.argv[1:]:
if len(sys.argv) < 2:
print("Syntax: python SpiderImagePlugin.py [infile] [outfile]")
sys.exit()

Expand All @@ -295,10 +293,6 @@ def _save_spider(im, fp, filename):
print("input image must be in Spider format")
sys.exit()

outfile = ""
if len(sys.argv[1:]) > 1:
outfile = sys.argv[2]

im = Image.open(filename)
print("image: " + str(im))
print("format: " + str(im.format))
Expand All @@ -307,7 +301,9 @@ def _save_spider(im, fp, filename):
print("max, min: ", end=' ')
print(im.getextrema())

if outfile != "":
if len(sys.argv) > 2:
outfile = sys.argv[2]

# perform some image operation
im = im.transpose(Image.FLIP_LEFT_RIGHT)
print(
Expand Down

0 comments on commit 0504029

Please sign in to comment.