Exemplo n.º 1
0
 def artwork(self, brep=False):
     """Get artwork for the song item
     brep determines if we want a PIL image or just the binary version
     """
     if self._objc.artworkCatalog():
         uiimage = self._objc.artworkCatalog().bestImageFromDisk()
         if brep:
             return uiimage_to_png(uiimage)
         else:
             i = BytesIO(uiimage_to_png(uiimage))
             return Image.open(i)
     else:
         return None
Exemplo n.º 2
0
 def artwork(self, brep=False):
     """Get artwork for the song item
     brep determines if we want a PIL image or just the binary version
     """
     if self._objc.artworkCatalog():
         uiimage = self._objc.artworkCatalog().bestImageFromDisk()
         if brep:
             return uiimage_to_png(uiimage)
         else:
             i = BytesIO(uiimage_to_png(uiimage))
             return Image.open(i)
     else:
         return None
Exemplo n.º 3
0
    def getIcon(self, scale=2.0, form=10):

        i = UIImage._applicationIconImageForBundleIdentifier_format_scale_(self.appID, form, scale)
        o = ObjCInstance(i.akCGImage())
        img = UIImage.imageWithCGImage_(o)
        with BytesIO(uiimage_to_png(img)) as buffer:
            self.icon = Image.open(buffer)
Exemplo n.º 4
0
    def getIcon(self, scale=2.0, form=10):

        i = UIImage._applicationIconImageForBundleIdentifier_format_scale_(
            self.appID, form, scale)
        o = ObjCInstance(i.akCGImage())
        img = UIImage.imageWithCGImage_(o)
        with BytesIO(uiimage_to_png(img)) as buffer:
            self.icon = Image.open(buffer)
Exemplo n.º 5
0
def get_symbols(assets_list):
    symbols = []
    for symbol in assets_list:
        ins = UIImage.systemImageNamed_(symbol)
        if ins:
            png = uiimage_to_png(ins)
            data = {'title': str(symbol), 'image': ui.Image.from_data(png)}
        else:
            data = {'title': str(symbol)}
        symbols.append(data)
    return symbols
Exemplo n.º 6
0
	def to_png(self):
		global depthSource
		ctx = objc_util.ObjCClass('CIContext').context()
		try:
			extent = self.ci_img.extent()
		except:
			if allow_ML:
				raise('The selected portrait photo does not contain a depth map.')
			else:
				print('The selected portrait photo does not contain a depth map.')
				quit()
		m = ctx.outputImageMaximumSize()
		cg_img = ctx.createCGImage_fromRect_(self.ci_img, extent)
		ui_img = objc_util.UIImage.imageWithCGImage_(cg_img)
		png_data = objc_util.uiimage_to_png(objc_util.ObjCInstance(ui_img))
		depthSource = 'Embedded'
		return png_data
Exemplo n.º 7
0
	def __init__(self, chosen_pic):
		self.MLModel = objc_util.ObjCClass('MLModel')
		self.VNCoreMLModel = objc_util.ObjCClass('VNCoreMLModel')
		self.VNCoreMLRequest = objc_util.ObjCClass('VNCoreMLRequest')
		self.VNImageRequestHandler = objc_util.ObjCClass('VNImageRequestHandler')
		
		result = self.classify_asset(chosen_pic)
		if result:
			resultString = str(result)
			resultWidth = int(resultString[resultString.find('width=') + 6:resultString.find(' ', resultString.find('width=') + 6)])
			resultHeight = int(resultString[resultString.find('height=') + 7:resultString.find(' ', resultString.find('height=') + 7)])
			CIImage = objc_util.ObjCClass('CIImage')
			pixelBuffer = result.pixelBuffer
			ci_img = CIImage.imageWithCVPixelBuffer_(pixelBuffer())		
			ctx = objc_util.ObjCClass('CIContext').context()
			cg_img = ctx.createCGImage_fromRect_(ci_img, objc_util.CGRect(objc_util.CGPoint(0, 0), objc_util.CGSize(resultWidth, resultHeight)))
			ui_img = objc_util.UIImage.imageWithCGImage_(cg_img)
			self.png_data = objc_util.uiimage_to_png(objc_util.ObjCInstance(ui_img))
Exemplo n.º 8
0
	def icon(self, scale=2.0, form=10):	
		i = UIImage._applicationIconImageForBundleIdentifier_format_scale_(self.appID, form, scale)
		o = ObjCInstance(i.akCGImage())
		img = UIImage.imageWithCGImage_(o)
		return uiimage_to_png(img)