image resize doesn't work

Chris Hare chare at labr.net
Sun Aug 1 11:36:07 EDT 2010


On Aug 1, 2010, at 10:24 AM, rantingrick wrote:

> On Aug 1, 7:35 am, Chris Hare <ch... at labr.net> wrote:
>> I have the following chunk of code.  Although it seems to execute fine, no errors
> 
> Not True! it contains syntax errors. Check the posted code and next
> time post all the code.
> -- 
> http://mail.python.org/mailman/listinfo/python-list

Hmmm... ok
here is the code.  I get no errors on my console when it execute

urllib.urlretrieve(findu, "image.png")
		logging.debug("createRadarWidgets(): radar download complete")
		logging.debug("createRadarWidgets(): user has radarPanelSize of " + root.radarPanelSize.get())
		#
		# open the image file
		#
        	if os.path.exists("image.gif"):
                	ctime = os.stat(dbPath)[ST_CTIME]
			print ctime
			filetime = datetime.fromtimestamp(ctime)
			filetime = filetime.strftime("%Y%m%d%H%M%S")
			print str(filetime)
			#filetime = datetime(ctime).isoformat()
			#print ctime
		imagePNG = Image.open("image.png")
		#photo = ImageTk.PhotoImage(imagePNG)
		Image.open("image.png").save("image.gif")
		image = Image.open("image.gif")
		photo = PhotoImage(file="image.gif")
		#photoimg = ImageTk.PhotoImage(photo)
		#
		# NOTE:	- will want to track the size of the image displayed based upon
		#	  the actual screen resolution
		#		Full/External = 600x550 - full file size
		#		Large = 450x412
		#		Medium = 300x275
		#		Small = 150x137
		#
		if root.radarPanelSize.get() == "Large":
			canvasWidth = 450
			canvasHeight = 412
		elif root.radarPanelSize.get() == "Medium":
			canvasWidth = 300
			canvasHeight = 275
		elif root.radarPanelSize.get() == "Small":
			canvasWidth = 150
			canvasHeight = 137
		logging.debug("createRadarWidgets(): creating image size " + str(canvasWidth) + "x" + str(canvasHeight))
		#
		# create a canvas of the appropriate size for the image
		#
		w = Canvas(f, width=canvasWidth, height=canvasHeight)
		if root.radarPanelSize.get() == "Off":
			logging.debug("createRadarWidgets(): no net, no radar")
			netRadarImage = Label(w, text="No current radar")
		else:
			#
			# convert it into a photo item we can use in the display
			#
			# photo = photo.resize((canvasWidth,canvasHeight),Image.ANTIALIAS)
			netRadarImage = Label(w, image=photo)
			netRadarImage.image = photo
		w.grid(row=1, column=0, columnspan=3)
		netRadarImage.grid( row=1, column=0)




More information about the Python-list mailing list