How to draw an reactangle with some text using python - python-3.x

I want to draw in an image using python3. I have implemented same thing in android application using java. Looking for something to be done on the web application. You can see at the bottom of the image where I have used paint in android.
My image is :
Sample Image
I am not getting any library or a code snippet to do so in python. Any suggestions will be a great help. Thanks

Pillow package provides the tools you need to add watermarks to your photos!
How to Watermark Your Photos with Python

Related

Converting sequence of SVG images (which contain Emojis) to a MPEG video

I googled and even asked chatGPT but I'm unable to find a solution and hope to get some guidance here.
First I've to mention that I'm not a programmer but rather a beginner.
Following a short description of what I'm trying to achive and what I've done so far.
I gather data and create a circular visualization using Circos which produces SVG
and PNG images.
(unfortunately the PNG doesn't give me the option of searching for
text an make replaecments), nevertheless I can use them to sucessfuly produce a
MPEG movie using FFmpeg. Therefore I need to use the SVG output to apply the
desired changes.
So I tried to use CairoSVG to render the SVG file to a PNG image but it does not
render emojis by default because the are not part of the SVG specification and
CairoSVG only supports features defined in the SVG specification. The Emojis are
stored as Unicode characters and are not natively supported in SVG
Next I tried to use PIL (Python Imaging Library) as it provides support for Unicode
characters, including emojis, when converting images to and from various formats.
Unfortunately PIL does not have native support for converting SVG files to PNG and
it seems that PIL is primarily designed for creating and manipulating images in a
variety of formats, but does not have built-in support for reading or converting
SVG files.
So now my questions are:
Would FFmpeg give me the desired results, if I compile it using the --enable-
librsvg option so it can convert a sequence of SVG images to a video but i'm not
sure if it supports emojis rendered correctly and want to spare me the hassle as
I'm pretty sure to struggle compiling it on my Mac running Ventura?
Are the maybe other ways or posibilities to solve that problem?
Many thanks in advance for your help or any hint :-)
Have all a nice weekend and take care
Regards,
Deekee
NB: an example of the circular visualization can be found here animated graph and the static version annotated graph
Problem solved, I used the html2image Python module which converts the SVG (including embedded Emoji's) nicely to a PNG image an then use those images to create a MPG4 video using FFmpeg.

How to have a background image in Altair Python

I'm trying to use Altair to have a dynamic map, I can easily do the dynamic part, however I am trying to add an image as background of the plot (bitmap image), I cannot find any functions in this purpose and every example on the Altair documentation is based on Url/Json feature. Does anyone have already done this kind of plot ? Is it possible to maybe combine a matplotlib with the background image and a dynamic part such as in Altair ?
Thanks Everyone,
Antoine.
It is not possible to embed a bitmap image within Altair. Vega supports an image mark, but that has not yet made its way into Vega-Lite, which drives the API of Altair.
Requests for this feature in Vega-Lite can be tracked in this GitHub Issue.

OpenCV 3: Why does the UI render incorrectly?

I am a new to openCV and trying its examples from documentation. I am doing the trackbar as the color palette example.
But my UI renders in wrong order as well as crops the switch title: OFF.
where it is supposed to be like this.
I am using macbook pro with macOS 10.13.
OpenCV's Highgui module uses QT as a backend. QT renders elements differently depending on the OS that is using it. I believe that this is because QT uses UI elements that are native to the OS. So a frame in Windows will look like a Windows Frame, a frame in Linux will look like a Linux frame.
This is what the same example produces in Windows:
You can get the slider bars to fit the window by changing:
cv2.namedWindow('image')
to:
cv2.namedWindow('image',cv2.WND_PROP_AUTOSIZE)
Doing that produces this output (in Windows):

How to make thumbnail images for custom Liferay Layouts?

How to make thumbnail images for custom Liferay Layouts? If anyone has done it using any open-source software, please help!
In Liferay 6.1 source folder /liferay-portal-src-6.1.0-ce-ga1/portal-web/docroot/layouttpl there is a zip file called thumbnails.zip which in turn contains thumbnails.psd, which contains thumbnail images for all the bundled layout templates. As for an open-source image image editing software, there is Gimp. Unfortunately, I didn't have much luck opening the mentioned file with it - the glossy overlay lost it alpha value and the large background rectangles seemingly lost their gradients and are all solidly colored. You could try Paint.net as well, which also stands in high regard among free image editing software.
The latest version of liferay docs containing any mention of layout templates thumbnails are for Liferay 6.0 series and you can find it here. There is also an empty png layout thumbnail template with proper background gradient, but you would have to make your own gloss over the little light rectangles as well as make the corners round...
All in all, you could also try to make the thumbnails from scratch, give them a more unique look. The image from Liferay docs should give you the idea of what it should like to still look nice next to bundled layouts' thumbnails. I'd just suggest to try and use vector image editing software. The bundled thumbnails all look simple enough to draw them with vectors, which would give you more flexibility and ability to change your mind anytime about details without having to draw everything all over again.
And that's for a 121x121 px image...

Using reportlab to build PDF with vector-based graphs generated by matplotlib

I'm trying to build PDF-documents on the server-side in a Django-Installation using reportlab. These documents should contain several graphs which are to be created with matplotlib.
I already figured out how to make reportlab use matplotlib's images without dumping them to the filesystem temporarily by passing PIL-Image objects directly to the Image()-flowable. This works surprisingly well for rasterized images formats like PNG.
Now, the icing on the cake would be able to embed vector based graphics (like SVG).
I used svglib to convert SVGs generated by matplotlib to reportlab graphic objects but unfortunately svglib does omit the tickmarks and axis labels. On some graphs it fails in general.
Do you have any ideas?
This page has a solution that I haven't had a chance to test myself yet: https://web.archive.org/web/20120725125858/http://lateral.netmanagers.com.ar/weblog/posts/BB753.html
You can generate matplotlib graphics as pdf and use pdfrw to embed it in reportlab canvas as described in this answer

Resources