Altering and showing uploaded image in Dash app - python

I'm new to Dash apps. I'm interested in creating a web app where the user uploads their own image, and then I alter it in some way, and show the resulting image (ideally using pillow v 6.0.0). A basic example would be to take in an image, rotate it, and show the rotated image. I've been using this example as a template for uploading an image and showing the same image. How can I alter the example to rotate the image rather than just displaying the same image?

Related

How to render an stl and save it as a png?

I am trying to render an stl and save it as a png so it is a preview of the stl.
I have a project that needs to take layer images(png) and save it as 3d(stl). I converted every layer image(approximately 300-400 image) to a numpy array. Then from those numpy arrays I made vertices and faces. My stl files are faces(triangles) aligned on top of each other. So there is no actual body in the final image just faces aligned together.(Layers have no z value)
Here is a single layer from one of my models:
And here is the final model:
And now I am trying to generate an image like the 2nd picture above. So there will be a preview of the stl model. And I am trying to figure a way out to save the preview as a png file. But I couldn't figure out the plot libraries' camera movements.
I tried matplotlib but i suppose there is no camera adjustment setting so it generates a png on a side that I do not want. That's why I want a way to control the camera. There is blender's Python API but it seems pretty confusing.
Any ideas on how to do that in Python?

Create an image having icon and text side by side with gradient background with PILLOW, Python

this is my first ever post on stackoverflow.
I want to create an image which I'll be using as a feature image on WordPress, the image will have an Icon and Text with a gradient background.
The icon will show on the left and text will show on the right (side-by-side), I've tried searching everywhere but found nothing relevant.
If any expert can show some example code that would be a great help. <3
Below i'm attaching an example of image which I want to create.
example image

Magnify image based on rectangle points selected on image

I am working on a code in python and I came across a figure in a report that I would like to replicate.
Basically I would like to create a 'bounding' box onto the original image, and then subsequently crop and display the part of the image that has the bounding box on it. (basically to 'magnify' that section)
I've been googling but I can't seem to find the correct function to use so that I can achieve this. Currently, opencv is used to read my image, but if there is a function in matplotlib that does this, then you can suggest that too.
Thank you for your help!

How to format and print Dash dashboard to PDF?

I've just created a dashboard in Dash, which fits automatically to my computer monitor and looks half decent. I now have the problem that I have to produce a way to print to PDF.
I've seen the Vanguard example which uses external CSS to format into an A4-size, and then a print button (using external javascript?). Is there a more 'Dash-native' way of doing this that doesn't require me to learn another programming language (I only know Python)?
There doesn't seem to be anything on the Dash User Guide https://dash.plot.ly/, all I've found is this https://plot.ly/python/pdf-reports/ which describes how to print individual plotly figures to pdf.
Ideally, it would format as it is now online (online layout) without losing space down the sides, and then I could use another layout (pdf layout) which could be printed out.
Any links or suggestions on how to proceed with this would be very much appreciated!
You can get pdf from plotly if save plot as png image (the most left option on image):
And then using that code convert png to pdf:
from PIL import Image
# Save your plot as png file (option "Download as png" in upper-left corner)
PNG_FILE = 'horizontal-bar.png'
PDF_FILE = 'horizontal-bar.pdf'
rgba = Image.open(PNG_FILE)
rgb = Image.new('RGB', rgba.size, (255, 255, 255)) # white background
rgb.paste(rgba, mask=rgba.split()[3]) # paste using alpha channel as mask
rgb.save(PDF_FILE, 'PDF', resolution=100.0)
If you are a lazy one, you can use library webkit2png check here how. This allowing you not clicking on Download as png button and just convert from html to png and then to pdf.

Rotated Image Orientation of Cellphone Pictures

I'm trying to display images on a simple html page, but it looks as though the image orientation of many of my pictures are rotated to the left, because they were taken by cellphone. The images are hosted on my computer.
I tried the css property image-orientation: from-image; but to no avail.
I used python's piexif library as well as PIL library to strip EXIF data, but the new stripped images still are rotated to the left.
I really feel as if there should be some simpler, standardized method of neutralizing the orientation of all of my images so that they naturally display upright?
Rotate and remove 'Orientation' of exif value.
http://piexif.readthedocs.io/en/latest/sample.html#rotate-image-by-exif-orientation

Categories

Resources