Overlaying text over images using PIL - python

Currently our application is restricted to text, images and audio mime types. I have been given the responsibility of adding a new feature - overlaying text on images (similar to snapchat). The image editing will be done on the server side (my task) and the text would be provided by the client using a jquery. I think that the ImageFont module of Python's Imaging Library (PIL) can be used to do this. So my question - how would I go about implementing this? Will the script be similar to this - http://python-catalin.blogspot.com/2010/06/add-text-on-image-with-pil-module.html ? Currently we are using amazon s3 for our object store. If I write the script in our DB API, Will it be major performance issue (the ultimate goal is to have a separate service for image processing)? I am quite new to Python and PIL so any help would be much appreciated.

Related

using python to download sentinel imagery directly

I'm trying to download sentinel satellite images directly using python.
the idea is to use sentinelsat API and a geojson polygon to download it.
however it downloads the entire image and not only the polygone.
is there a way to make it download only the polygon or to automatically crop the wanted area?
thank you in advance
There are a few ways you can go about it, but, based on the documentation, sentinelsat doesn't support such an operation. The easier would be to use gdal and a geojson or shapefile. The way how you can do that is answered here.
The much more complicated way, which also gives you immensely more control on what data you can download is with the Sentinel-2 AWS S3 Buckets and the GDAL python api. Specifically, GDAL has a driver called S3 that allows you to load a raster into memory without downloading it locally. Then, you can use the ReadAsArray function to load specific parts of the image. You can look these bits up from the GDAL docs.

Is pytesseract safe to use with confidential images?

I am working on a project for my company which tries to read scanned pdfs and classify them depending on their contents.
After doing some research online, the easiest way to solve this seems to be by using a Python Library called pytesseract.
My question is: Is this library safe to use with images containing confidential customer data? Do the images/the extracted text get saved in some server?
I found this link which suggests that it is. But I am lacking understandment of what exactly happens 'behind the scenes' everytime I read an image with the module.
Thanks in advance for any help!

How to deliver an image array from python to Rails

I am new to the world of Web Developing, i am currently using Ruby on Rails to code my webpages.
Here is the problem i am facing right now.
I am trying to make a webapp (using ruby on rails) in which the user must submit an Image(i am using CarrierWave for this) and the program its suppose to do some image processing, recognized objects and count them, so for this task i made a python script which do this automatically(using OpenCV). My problem is that the python script must return a new image which has the objects of interest in rectangles, and then i must store it in the dabase.
Currently i am returning in console where my objects are in the image, and displaying the new image, but i am not able to return the image as an array so that ruby framework can process it and upload it.
A simple view at how i am doing this
In the example1 i am recognizing oranges in the trees.
If anyone can help me or have an idea at how to do it, maybe a different approach could work. I am new in this, i have researched everywhere with no goods results. I didn't want to pose any code because i dont know which part is useful or not. (sorry for my bad english, i am not use to it completely)
To save an image locally into python you need to make an Image object and then save it to a given path.
my_image= Image("simplecv")
my_image.save("my-image.png") # in the current working directory
or to a path :
my_image.save("path/to/img.png")
You can then re-load those files with another language and store them in a database.
More examples on :
http://tutorial.simplecv.org/en/latest/examples/basics.html

Python Library to read wavefront object and Render it to JPEG file

I have a very specific requirement, which is to :
1. read a obj file created in 3dsMax.
2. apply camera perspective projection on it
3. save the output in jpeg or any other image format
Please if someone could help me find a library or code to do this in python.
I have looked at pyglet, & pywavefront but could not succeed.
I want to build a web service for this use case hence the library has to be robust.
Please help me find the right tools.
The simplest way probably would be to write a script with 3ds max api or maya api..
OBj are simple, You can write an importer by yourself, that is just a file with ASCII text, with position of verticles.
As about
You can also use Away3D or simmilar. This may probbalby work in a browser

mpeg-1 video writing with python

I am trying to use the Opencv VideoWriter object with the mpeg-1 encoding to create videos, I am aiming at writing only two images on that video, using mpeg-1 encoding, I would like to know how much the first image that I wrote first helps in compressing the second image. In other words find the file size before writing the 2nd image and after. My questions are:
Is there any way to perform this process using Opencv?
Is there a way to avoid writing on disks and just have the information of the size of the compreesed video( after adding the second image)?
Is there any other good alternatives reach my goals?
I suggest you learn GStreamer framework which has Python bindings available.
http://gstreamer.freedesktop.org/modules/gst-python.html
It works best on Linux platforms, some OSX support is available.
GStreamer provides "sane", but very powerful and very complex, APIs for procedural video and audio generation.
See also:
GStreamer: status of Python bindings and encoding video with mixed audio
Alternative you can write out frames to raw image images files and parse them to a video using ffmpeg command. Might work on Microsoft Windows platforms too.

Categories