Code Monkey home page Code Monkey logo

Comments (3)

cvpe avatar cvpe commented on July 24, 2024

Please try this workaround

import ui

url = "https://a.ltrbxd.com/resized/film-poster/3/6/9/9/8/36998-darling-0-1000-0-1500-crop.jpg"
		
def load_image(): 
	iv.load_from_url(url)

iv = ui.ImageView()
iv.present()

# to understand why to use a delay, see topic (from 2015) 
# https://forum-new.omz-software.com/topic/1639/imageview-load_from_url-freezes-app
ui.delay(load_image,0.0)

# if you want a PIL image, you can still convert ui.Image to PIL
from PIL import Image
from io import BytesIO

def ui2pil(ui_img):
	png_data = ui_img.to_png()
	return Image.open(BytesIO(png_data))
	
pil_image = ui2pil(iv.image)
pil_image.save('out.png')

from pythonista-issues.

cclauss avatar cclauss commented on July 24, 2024

Caution: BytesIO(png_data) allocates memory but never closes (frees) that memory. If you process many images, this may cause Pythonista to crash.

from pythonista-issues.

cvpe avatar cvpe commented on July 24, 2024

Caution: BytesIO(png_data) allocates memory but never closes (frees) that memory. If you process many images, this may cause Pythonista to crash.

Thanks, forgotten, some neurons were removed by my operation ๐Ÿ˜ข But not sure that somebody else would read my comment

from pythonista-issues.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.