image metadata, Can I add custom fields or comments? - django

I am a bit lost on what to do here. I have a django app that will be using a lot of images and I want to keep track of the source of all these images.
I had it setup to have a model that has two fields (FilePath and Char) that I would use to store the image path and the source, but now I am thinking that is a waste of energy. I would like to store the source right with the image.
What would be the best way to go about this?
(possibility) I see in my OSX finder that there is something called comments, can these be accessed across all machines or is this OSX specific?

The answer turned out to be definitely no. I will have to be adding another model field to store this information

Related

Django Upload File, Analyise Conents and write to DB or update form

I'm pretty new to Django, Trying to get my grips with it, and expand what I think its capable of doing, and maybe one of you more intelligent people here can point me in the right direction.
I'm basically trying to build a system similar to a so called "Asset Management" system, to track software version of a product, so when an engineer updates the software version, they run a script which gathers all the information (Version, Install date, Hardware etc), which is stored in a .txt file, The engineer then comes back to the website and upload this .txt file for that customer, and it automatically updates the fields in the form, or directly to the database.
While, I've search a bit on here for concepts, I haven't been able to find something similar (Maybe my search terms aren't correct?), and wanted to ask if anyone knows, what I'm doing is even feasible, or am I lost down the rabbit hole of limitations :) Maybe its not do-able within Django, Any suggestions on how I should approach such a problem would be greatly appreciated.
What you're asking is doable both in the form and post-submit of a form or file upload.
In the form approach you'll want a live-reload of the form should the data come from a .txt file. That can be done with JavaScript. This will mean that the data will come from the text file and be input into the forms in the manner you define. This also means form validation will work as you want it to.
Another option is to require a txt file in a specified format, and parse it in the view, form_valid() for Class-Based Views, and request.FILES[] for function based views, and then perform all the required validations and then save the values to the database as the model instance.

CiviCRM CiviMail Images are relative URLs

When using the CiviMail WYSIWYG to compose a mailing, clicking the image insert option and then choosing "browse server", then uploading an image and inserting it - results in a broken image in the sent email because it uses a relative URL for the image.
Given that this is CiviMail and its sole purpose is to send out mailings, it seems like this behavior should be gleaned and replaced prior to sending? Is there an extension or way to configure it to fix this? I recall this being an issue previously, but had thought this was resolved for 4.5. Anyone know if there is a way to configure without jumping into the wysiwyg's direct code and overriding?
the editor is used in multiple locations besides civimail
Might want to check see if the wysiwyg editor has a setting that decides between relative vs absolute urls. might want to tweak that setting and see if it fixes things

Ways to handle thumbnails with Django?

I'm going to have different ways to present an objects image in my templates. Full size, medium size and smaller thumbnails in lists. It's a dynamic structure and needs to be fast for sorting, searching, filtering..
As a beginner I'm thinking of three ways to handle this:
Simply use the image from the image field and change the size in templates with css.
Save different image versions (size) in different fields in the model and in media files.
Create the thumbnails dynamically in the templates with sorl-thumbnail or easy-thumbnails
The thumbnail apps is a bit complicated and would need some extra requirements like PIL and I need to make some choices about caching. Not sure if I win so much performance by going down this path or if there is other smarter ways? Is it better to plan ahead for scaling/performance.
How are you handling thumbnails? And are you using redis or memcached?
First neither redis or memcached handles caching of images. Memcached is a simple key-value store. Redis essentially works as a key-value store but it has support for other types as well. Such as lists. When it comes to caching images you would use something like nginx.
Secondly, the first option is suboptimal if you want your page to load as quickly as possible. As it will need to load a bigger file than necessary. The second and the third option is essentially the same. Easy-thumbnails for example doesn't create thumbnails on the fly in the template. It generates them as needed and then you can access those thumbnails from your static_folder.
If you want to manipulate images, you will need PIL or Pillow if you're using Python 3.

django image management

In my project I'am working with images. I don't know how to organize the management of images.
I need to dynamically upload the pictures and resize them.
First question - what is the best way to dynamically upload images with progress bar and without flash? I found this and this, but I believe there is a better way.
Second question. I have to save one image in different sizes. I won't use these thumbnails on my pages, but another application will. Many clients could upload images at the same time. This means that I can not resize all the images at the same time. How should I organize this process?
Is there are a better ready-to-use solution for image management issue?
django-photologue could be a good starting point for organizing the management of your images.
The PhotoSize model can be used to automatically resize/crop your images, and the GalleryUpload model allows the user to upload an archive of images.
You can also create PhotoSize models with pre_cache = False. This means that your images will dynamically created the first time they are requested.
For your second question you might use a task queue, like django-celery or django-tasks.
For the image crop, try Python Imaging Library (PIL)

User-Defined Thumnails for Django Project?

I'm putting together a Web site that makes heavy use of images. Those images need to be thumbnailed at various sizes to fit different templates.
I'm aware of solutions like sorl-thumbnail, which seems perfect in every way except one: I need to be able to override automatic resizing and cropping if the computer's choice is a bad one.
For instance: Say I upload a 1,000-by-1,000 pixel image. I need a 300-by-200 thumbnail of that image. The sorl-thumbnail solution, if I understand it right, is to rescale the image to 300-by-300 and then lop off the top and the bottom.
What I want to be able to do is a) accept the sorl-style solution if it works for the image, but b) be able to override the sorl choice -- in the admin, probably -- if that would work better. If it's a picture of a person, for example, maybe I would rather crop out the person's torso and just make a thumbnail out of her face, which happens to be located in the upper right corner?
There's no off-the-shelf pluggable solution for this, so far as I can tell (but please correct me if I'm wrong). Barring that, I'd like to hear your ideas about ways that the problem might be approached. Is there some sort of jQuery plugin that will get me halfway there?
Help!
If you want to use an off-the-shelf pluggable there is django-photologue django-imagehandler. It allows you to generate thumbnails and do "manual-cropping" on the admin.
Another off-the-shelf solution is django-thumbs. django-thumbs overwrittes your imagefields. The only drawback is that you need to set up the sizes it will generate the thumbnails.
None of these 2 applications can fully solve your problem. But atleast you know where to start :)
django-photologue can generate thumbnails and add effects and watermarks.
EDIT: if you want to use jQuery to crop your images then you can take a look at jCrop. It's pretty easy to use. The main problem is that you will need to upload the image to your server and then crop it manually.
EDIT 2:Wrong information. It was not django-photologue but django-imagehandler.
sorl-thumbnail has smart cropping which will cut off the parts of the image with the least entropy. All you need to do is add crop="smart". It works really really well in most situations.
Otherwise you could check out django-imagehandler