0

Hello I am using following code. It plot the small images properly, but I want to plot long image and it has been truncated. It seems if the image width/height is more than 35000 pixels it does not show pixels grater than 35000. I have used bokeh library and I got the same issue. Any idea, what can be added to my code or any solution to overpass this limitation:

from tkinter import *
from PIL import Image
from PIL import ImageTk
import tkinter.filedialog as fdialog
import cv2



class ScrolledCanvas(Frame):

 def __init__(self, parent=None):
      Frame.__init__(self, parent)

      self.master.title("Spectrogram Viewer")
      self.pack(expand=YES, fill=BOTH)
      canv = Canvas(self, relief=SUNKEN)
      canv.config(width=140, height=200)
      canv.config(highlightthickness=0)
      sbarV = Scrollbar(self, orient=VERTICAL)
      sbarH = Scrollbar(self, orient=HORIZONTAL)
      sbarV.config(command=canv.yview)
      sbarH.config(command=canv.xview)

      canv.config(yscrollcommand=sbarV.set)
      canv.config(xscrollcommand=sbarH.set)

      sbarV.pack(side=RIGHT, fill=Y)
      sbarH.pack(side=BOTTOM, fill=X)

      canv.pack(side=LEFT, expand=YES, fill=BOTH)
      #self.im=Image.open("./1hr_original.jpg")
      self.filename = fdialog.askopenfilename(filetypes=(("Image files", "*.jpg *.png"), ("All files", ".")))
      self.im = Image.open(self.filename)

      width,height=self.im.size
      canv.config(scrollregion=(0,0,width,height))
      self.im2=ImageTk.PhotoImage(self.im)
      self.imgtag=canv.create_image(0,0,anchor="nw",image=self.im2)



ScrolledCanvas().mainloop()

0 Answers0