def _getImagePreview(self, filename): dim = 128 if isStandardImage(filename): self.tkImg = gui.getImage(os.path.abspath(filename), tkImage=True, maxheight=dim) else: fn = self._index + filename self.tkImg = getTkImage(self._image, fn, dim) return self.tkImg
def __init__(self, canvas, imgPath, x=0, y=0, text=None): Item.__init__(self, canvas, x, y) # Create the image from pyworkflow.gui import getImage, getImageFromPath if imgPath is None: self.image = getImage('no-image.png') else: self.image = getImageFromPath(imgPath) if text is not None: self.label = tk.Label(canvas, image=self.image, text=text, compound=tk.TOP, bg='gray') self.id = self.canvas.create_window(x, y, window=self.label) self.label.bind('<Button-1>', self._onClick) else: self.id = self.canvas.create_image(x, y, image=self.image)
def _getImagePreview(self, filename): # If file size if big if pwutils.getFileSize(filename) > (pwem.Config.MAX_PREVIEW_FILE_SIZE * 1024 * 1024): return dim = 128 if isStandardImage(filename): self.tkImg = gui.getImage(os.path.abspath(filename), tkImage=True, maxheight=dim) else: fn = self._index + filename self.tkImg = getTkImage(self._image, fn, dim) return self.tkImg
def get_image(request): imageNo = None # TO DO: Change the way to obtain the separate string of the imagePath imagePath = request.GET.get('image') imageDim = request.GET.get('dim', 150) # This prefix can be passed to avoid that image is not refresh when cached by browser (name does not change) prefix = request.GET.get('prefix', "") mirrorY = 'mirrorY' in request.GET applyTransformMatrix = 'applyTransformMatrix' in request.GET onlyShifts = 'onlyShifts' in request.GET wrap = 'wrap' in request.GET matrix = request.GET.get('matrix',None) try: # PAJM: Como vamos a gestionar lsa imagen if imagePath.endswith('png') or imagePath.endswith('gif'): imagePathTmp = os.path.join(request.session['projectPath'], prefix + imagePath) img = getImage(imagePathTmp, tkImage=False) else: if '@' in imagePath: parts = imagePath.split('@') imageNo = parts[0] imagePath = parts[1] if 'projectPath' in request.session: imagePathTmp = os.path.join(request.session['projectPath'], imagePath) if not os.path.isfile(imagePathTmp): raise Exception('should not use getInputPath') #imagePath = getInputPath('showj', imagePath) if imageNo: imagePath = '%s@%s' % (imageNo, imagePath) imgXmipp = xmipp.Image() imgXmipp.readPreview(imagePath, int(imageDim)) #=================================================================== # Transform Matrix if applyTransformMatrix: takarras=[tMatrix[0][0], tMatrix[0][1], tMatrix[0][2], x if x!=None else 0, tMatrix[1][0], tMatrix[1][1], tMatrix[1][2], y if y!=None else 0, tMatrix[2][0], tMatrix[2][1], tMatrix[2][2], z if z!=None else 0] # imgXmipp.applyTransforMatScipion(matrix, onlyShifts, wrap) imgXmipp.applyTransforMatScipion(takarras, onlyShifts, wrap) #=================================================================== #=================================================================== # Invert Y axis if mirrorY: imgXmipp.mirrorY() #=================================================================== #TO DO: PSD FIX if imagePath.endswith('.psd'): imgXmipp.convertPSD() # from PIL import Image img = getPILImage(imgXmipp, None) except Exception: img = getImage(findResource(getResourceIcon("no_image")), tkImage=False) response = HttpResponse(mimetype="image/png") img.save(response, "PNG") return response
def get_image(request): imageNo = None # TO DO: Change the way to obtain the separate string of the imagePath imagePath = request.GET.get('image') imageDim = request.GET.get('dim', 150) # This prefix can be passed to avoid that image is not refresh when cached by browser (name does not change) prefix = request.GET.get('prefix', "") mirrorY = 'mirrorY' in request.GET applyTransformMatrix = 'applyTransformMatrix' in request.GET onlyShifts = 'onlyShifts' in request.GET wrap = 'wrap' in request.GET matrix = request.GET.get('matrix', None) try: # PAJM: Como vamos a gestionar lsa imagen if imagePath.endswith('png') or imagePath.endswith('gif'): imagePathTmp = os.path.join(request.session['projectPath'], prefix + imagePath) img = getImage(imagePathTmp, tkImage=False) else: if '@' in imagePath: parts = imagePath.split('@') imageNo = parts[0] imagePath = parts[1] if 'projectPath' in request.session: imagePathTmp = os.path.join(request.session['projectPath'], imagePath) if not os.path.isfile(imagePathTmp): raise Exception('should not use getInputPath') #imagePath = getInputPath('showj', imagePath) if imageNo: imagePath = '%s@%s' % (imageNo, imagePath) imgXmipp = xmipp.Image() imgXmipp.readPreview(imagePath, int(imageDim)) #=================================================================== # Transform Matrix if applyTransformMatrix: takarras = [ tMatrix[0][0], tMatrix[0][1], tMatrix[0][2], x if x != None else 0, tMatrix[1][0], tMatrix[1][1], tMatrix[1][2], y if y != None else 0, tMatrix[2][0], tMatrix[2][1], tMatrix[2][2], z if z != None else 0 ] # imgXmipp.applyTransforMatScipion(matrix, onlyShifts, wrap) imgXmipp.applyTransforMatScipion(takarras, onlyShifts, wrap) #=================================================================== #=================================================================== # Invert Y axis if mirrorY: imgXmipp.mirrorY() #=================================================================== #TO DO: PSD FIX if imagePath.endswith('.psd'): imgXmipp.convertPSD() # from PIL import Image img = getPILImage(imgXmipp, None) except Exception: img = getImage(findResource(getResourceIcon("no_image")), tkImage=False) response = HttpResponse(mimetype="image/png") img.save(response, "PNG") return response