libjpeg PIL django image display - django

I installed PIL.
I can import PIL (with no error message)
Then I ran the code mentioned here:
Python images display
And I get this error message:
IOError: decoder jpeg not available
I understand this is Library called libjpeg and (?) it should be installed already.
Or is it part of PIL?
Where is it installed if so?
And if not where can I download it?
What I would like to achieve (and seem to run in one problem after the other), would be simply explainable as a Webgallery which I than want to tweak. But first I need Django to get images from the MEDIA_ROOT and display them in the browser when somebody calls a URL. And then I need one button (Next).
And if Christmas and Easter will fall on the same day I want to get the timestamp of that button click.
I thought that would be a breeze. But now I am in a storm of libjpeg and PIL an Tkinter and Models and photologue and ImageField() and.
If anybody has done that (I guess any simple Image display on a Blog) I would be very very glad to hear this expierence.
I somehow cant understand the standard way to do this and every time I think I have the solution, there is some library missing or it is slightly not what I was looking for.
Thanks for the time!

I wrote an article on how to get libjpeg, PIL to work on Snow Leopard.
http://appelfreelance.com/2010/06/libjpeg-pil-snow-leopard-python2-6-_jpeg_resync_to_restart/
Hope you might find this handy

Try this: http://rodesia.org/2008/03/14/installing-pil-on-the-mac/

Related

Why does pm4py.view doesn't generate any image

For a business process discovery task, I am trying to generate a process model, following pm4py python library. Here's a sample code:
!pip install pm4py
import pm4py
log = pm4py.read_xes('/content/running-example.xes')
process_model, initial_marking, final_marking = pm4py.discover_petri_net_inductive(log)
pm4py.view_petri_net(process_model, initial_marking, final_marking, format="svg")
However, I get output as:
parsing log, completed traces :: 100%
6/6 [00:00<00:00, 121.77it/s]
But no image as is expected from the website: https://pm4py.fit.fraunhofer.de/getting-started-page#discovery
Being relatively new to the world of python, what I learnt from other coders' suggestions here on SO that always read in depth the source code in case of open source libraries.
Here is pm4py visual links:
https://github.com/pm4py/pm4py-core/blob/afee8b0932283b8f8f02dd2b6cc0968a1f1cc723/pm4py/visualization/process_tree/visualizer.py#L69
and specifically for my example:
https://github.com/pm4py/pm4py-core/blob/afee8b0932283b8f8f02dd2b6cc0968a1f1cc723/pm4py/vis.py#L17
But I am not able to figure out how to manipulate it.
Can someone please point out the problem to me and help me generate the views. Also, if anyone has done business process generations before, maybe if you could suggest me any libraries or techniques to analyse event-logs data it would be really helpful.
to visualize the process models mined in PM4Py, make sure that you have graphviz installed on your computer.
see https://pm4py.fit.fraunhofer.de/install for more information on this.

Django Video Encoding package not converting videos

hey guys I am trying to make the django-video-encoding package work with my code, but it doesn't seem to be converting the videos. I have followed exactly as per the documentation. Can someone help with checking the code I have if I missed anything??
This is the link to the package: https://github.com/escaped/django-video-encoding
Can anyone tell me where I went wrong? I couldn't see any tutorials or much info regarding this package but it seems like its the only one there.
I have given the path to ffmpeg like this (am not sure whether its the right way to provide path). this is in settings.
VIDEO_ENCODING_FFMPEG_PATH = "c:\\ffmpeg\\bin\\ffmpeg.exe"
in my signals.py I have this.
#receiver(post_save, sender=VideoPost)
def convert_video(sender, instance, **kwargs):
enqueue(tasks.convert_all_videos, instance._meta.app_label, instance._meta.model_name, instance.pk)
print('Done converting!')
and this prints after I upload a video, but the conversion does not happen.
I tried to recreate but everything seems smooth to me. I didn't point the ffmpeg location though as I set it up in the PATH instead. Try to to set the ffmpeg as global(system) variable instead.

Modify an image on Google App Engine using PIL Library

I am currently trying to deploy a python(2.7) application on the GAE, but I seem to have run into a wall doing so.
In the application I need to apply some transformations on an image's data which I have retrieved in the form of an array of bytes. I proceeded as pointed out by the OP of this question. Everything seems to go fine, until I wish to retrieve back the image's data from the PIL.Image object. The code is:
def transform_image(im_data,ratio):
im = Image.open(BytesIO(im_data))
w,h = im.size
im = im.crop((0,0,w,h-20))
new_b_io = BytesIO()
im.save(new_b_io,format='JPEG')
im.close()
return new_b_io.getvalue()
#I write this data to a new '.jpg' file on my GCS bucket.
Looking at my GAE application logs, the exception being raised is:
UnsupportedOperation: fileno
This is an identified bug with the PIL version 1.1.7 (the only PIL version available with GAE), as pointed out here.
Looking everywhere, all I could manage to understand is to use a more latest version of PIL (preferably Pillow), but as one would imagine, our friends at Google haven't made that an option. I could move to the Google's Image Processing API, but I'd appreciate if I could make my way through with PIL.
I'd appreciate if someone could walk me through this dilemma.
Thanks for your time.

How to batch download large number of high resolution satellite images from Google Map directly?

I'm helping a professor working on a satellite image analysis project, we need 800 images stitching together for a square area at 8000x8000 resolution each image from Google Map, it is possible to download them one by one, however I believe there must be a way to write a script for batch processing.
Here I would like to ask how can I implement this using shell or python script, and how could I download images by google maps url ?
Here is an example of the url:
https://maps.google.com.au/maps/myplaces?ll=-33.071009,149.554911&spn=0.027691,0.066047&ctz=-660&t=k&z=15
However I'm not able to analyse the image direct download link from this.
Update:
Actually, I solved this problem, however due to Google's intention, I would not post the way for doing this.
Have you tried the Google static maps API?
You get 25 000 free requests, but you're limited to 640x640, so you'll need to do ~160 requests at a higher zoom level.
I suggest downloading the images as so: Downloading a picture via urllib and python
URL to start with: http://maps.googleapis.com/maps/api/staticmap?center=-33.071009,149.554911&zoom=15&size=640x640&sensor=false&maptype=satellite
It's been long time since I solved the problem, sorry for the delay.
I posted my code to github here, plz star or fork as you like :)
The idea is to use a virtual web browser at a very high resolution to load the google map page, then do the page capture. The defect is there will be google symbol all around on each image, the solution is to apply over sampling on the resolution on each of the image, then use the stiching technique to stick them all together.

Doing sophisticated image analysis with python / django

I am working on a django project that analyzes images that contain text and (1) infers if the image needs to be rotated and (2) where text areas are.
I am currently using PIL to do some more simpler processing of these images but I am not quite sure how I can use PIL or other libraries to perform both tasks. I was wondering if anyone has done this before and if there are libraries / api available to help in the development.
OpenCV is probably the post popular open source image processing library. It's C/C++ but there are python bindings:
http://opencv.willowgarage.com/wiki/
and the python docs
http://opencv.willowgarage.com/documentation/python/index.html
I've never done an OCR with it, but I'm sure it's capable
I agree with #pastylegs that OpenCV is your best initial bet. If you need stuff specific to OCR you could also look at ocropus.