djangosnippets.org: Latest snippets tagged with 'image'https://djangosnippets.org/tags/image/2023-05-24T14:14:07.813738-05:00Image compression before saving the new model / work with JPG, PNG
2023-05-24T14:14:07.813738-05:00Schleidenshttps://djangosnippets.org/snippets/10949/<p>Don't forget to replace "self.image" by your image field name from your model ex ( self.cover )
replace Product by your model name</p>
<p>works pretty well :)</p>
Freely redistributableRead image url as base64
2020-01-28T21:17:43.951410-06:00agusmakmunhttps://djangosnippets.org/snippets/10763/<p>Read the image url as base64 in django, this snippet usefull if you using the <code>django-easy-pdf</code> to solve this issue https://github.com/nigma/django-easy-pdf/issues/53</p>
<p>Usage example:</p>
<p><code><img src="{{ profile.photo.url|read_image_as_base64 }}"></code></p>
Freely redistributableImage as base64 in django
2017-08-04T03:58:03.628132-05:00agusmakmunhttps://djangosnippets.org/snippets/10616/<p>Easy way to get base64 for the image to display in the template, eg: <code><img src="{{ post.get_cover_base64 }}"></code></p>
Freely redistributableSimply Gravatar Templatetags
2017-01-10T19:38:30.271719-06:00agusmakmunhttps://djangosnippets.org/snippets/10600/<p>Simply Gravatar Templatetags, for example the name of this templatetag is: <code>templatetags/gravatar_tags.py</code>, this supported for Python2 or Python3. </p>
Freely redistributableDjango Ajax Image Uploader
2017-01-06T12:30:54.644778-06:00agusmakmunhttps://djangosnippets.org/snippets/10598/<p>Django Ajax Image Uploader, this what we do for: https://github.com/agusmakmun/dracos-markdown-editor/</p>
Freely redistributableResize or Modify an image before saving
2016-12-29T10:30:09.721190-06:00asurahttps://djangosnippets.org/snippets/10597/<p>Small snippet that will resize all images before they uploaded to the server. </p>
Freely redistributableDownload an image using requests, resize it using PIL, and save it to a model ImageField.
2015-03-24T19:31:51.304922-05:00stewxhttps://djangosnippets.org/snippets/10473/<p>You can use this as a model method.</p>
Freely redistributableImage compression and conversion to JPG format before uploading the file
2015-01-26T09:57:55.487301-06:00monikkinomhttps://djangosnippets.org/snippets/10460/<p>I've reimplemented the code I found somewhere on the web within my models file. The earlier version was incapable of converting all formats to JPG while this code converts all formats and compresses all of them successfully. </p>
<p>You need to have PILLOW installed for this to work.</p>
Freely redistributableImage compression and conversion to JPG format before uploading the file
2015-01-26T09:46:48.316864-06:00monikkinomhttps://djangosnippets.org/snippets/10459/<p>I've reimplemented the code I found somewhere on the web within my models file. The earlier version was incapable of converting all formats to JPG while this code converts all formats and compresses all of them successfully. </p>
Freely redistributableSave an image to ImageField from URL
2012-10-27T22:46:09.646734-05:00ekinertachttps://djangosnippets.org/snippets/2838/<h4>this is the right and working way</h4>
Freely redistributableImage Widget (for admin)
2012-07-20T15:32:24.749512-05:00moskrchttps://djangosnippets.org/snippets/2792/<p>class ImageInline(TabularInline):
formfield_overrides = {
models.ImageField: { 'widget': ImageWidget },
}</p>
Freely redistributabletxt2img tag to show on the web text as images
2012-04-29T06:53:27.600034-05:00br0th3rhttps://djangosnippets.org/snippets/2737/<p>txt2img tag shows on the web text as images, helping to avoid get indexed email address and some other information you don't want to be on search engines.</p>
<p>Usage:
<code>{{worker.email|txt2img:18|safe}}</code></p>
Freely redistributableSignal to resize uploaded Fiber images as new thumbnailed images
2012-02-13T18:45:06.854535-06:00versaehttps://djangosnippets.org/snippets/2684/<p>You only have to put the code in some of your models.py and to have django-fiber installed in your system. Every image uploaded using Fiber admin dialog will be automatically resized and thumbnailed. Or whatever you need to do with it.</p>
Freely redistributablesave image from url to django ImageField
2011-11-01T05:13:13.192196-05:00kriwilhttps://djangosnippets.org/snippets/2587/<p>Saves image from a url into django's ImageField in a model.
Uses <a href="http://pypi.python.org/pypi/requests/">requests</a> library.</p>
Freely redistributableA Django form field that accepts an uploaded image and creates a resized image attached with a push-pin
2011-05-30T21:00:23.741751-05:00rmisiohttps://djangosnippets.org/snippets/2449/<p>PushPinImageField is a Django form field that is a sub-class of an ImageField. The field accepts an image to upload and based on certain settings, notably the size of the resulting image, the sizes and colors of 3 different borders, as well as the color of the push pin, a …</p>
Freely redistributable