Commit graph

566 commits

Author SHA1 Message Date
Chris McKenzie
6412e40c69 adding test for new api 2011-09-26 16:38:55 -04:00
Matthew Tretter
da00e2a5da Moved Crop and Fit to resize module.
Crop doesn't necessarily imply the any scaling is taking place. Several
ideas were discussed, from renaming Crop to combining both processors
into a single Resize processor (as they were in the original IK), but
those solutions were felt to either precluded future extension
(alternative resize modes) or make the API too verbose.
2011-09-26 14:40:48 -04:00
Matthew Tretter
6751d78504 More docs edits.
Added us to the authors. Reorganized some of the documentation so that
sphinx and the project landing page on github can share it.
2011-09-26 11:36:08 -04:00
Bryan Veloso
cec46b3176 Merge pull request #32 from ryanbagwell/develop
Trasparency preservation patch
2011-09-26 03:06:04 -07:00
Matthew Tretter
6adbef3475 Embracing duck typing.
ImageProcessor didn't do anything. I'd rather get it out of there to reduce the
temptation for future IK contributors to do type checking and mess up peoples'
custom processors.
2011-09-25 23:24:44 -04:00
Matthew Tretter
d6632c95f5 Documentation! 2011-09-25 21:04:11 -04:00
Ryan Bagwell
ff07e4e247 dynamically getting colors, instead of setting it to 255 2011-09-25 17:53:51 -05:00
Ryan Bagwell
b96a3f53a5 adding transparency patch to preserve transparency when saving the image 2011-09-25 15:49:32 -05:00
Matthew Tretter
51144daeb6 Fix bug
Eric's fixes in c00ea10b0a meant that
some of the code that already existed to reuse objects would actually
be run for the first time. Naturally, there were some bugs; namely, I
was storing a filename (instead of a File object) in `_file` and a bad
else clause.
2011-09-25 16:18:52 -04:00
Eric Eldredge
c00ea10b0a Bound fields are now cached on the model instance.
ImageSpecFile and AdminThumbnailView are created on the first access, and
then assigned as properties of the model instance for subsequent access.
2011-09-25 12:42:27 -04:00
Eric Eldredge
f570bd0d7f Transpose processor now supports auto EXIF orientation.
Replaced calls to Image.open with an open_image utility function.
The open_image utility calls Image.open, but then wraps the opened Image's
copy method with a version that preserves EXIF data. This allows an
ImageSpec to copy the original image, yet still provide all the original
image's exif data to the processor pipeline.
2011-09-24 23:09:49 -04:00
Matthew Tretter
c694ba644f Fix filename formatting. 2011-09-24 02:04:23 -04:00
Matthew Tretter
6ae4f56ed7 Eliminate repetition in File objects. 2011-09-24 02:04:23 -04:00
Matthew Tretter
f9c4d6b500 Cleanup.
Centralized access of _img, tried to reduce re-calculation of some
properties, renamed _imgfield to source_file to reflect the fact that
it's an ImageFieldFile and not an ImageField.
2011-09-24 02:04:23 -04:00
Matthew Tretter
cc96ba5198 Moved _get_imgfile() into _create()
That was the only place it was being called and it just led to (my)
confusion with the image property.
2011-09-24 02:04:23 -04:00
Eric Eldredge
8a0bc084fe Processors no longer take a file argument.
They only get the image to process now.
2011-09-23 21:25:47 -04:00
Eric Eldredge
d99bf5327b Transpose processor has a new API.
Transpose now takes transposition constants as arguments. Multiple
transpositions can be sequenced together in one Transpose processor.
Auto transposition is not yet supported (PIL strips the EXIF data, so need to
find a workaround for getting that data to the processor).
2011-09-23 21:23:21 -04:00
Matthew Tretter
7e20b75ced Processors don't care about format.
The process of choosing an image format has been cleaned up and
Processors' role in determining the format has been removed.

Previously, processors would return a tuple containing the modified
image and the format. Other parts of IK overrode PIL's Image.format
with the target format, although that had no effect on PIL and the fact
that it didn't throw an error was just lucky.
2011-09-23 20:18:51 -04:00
Matthew Tretter
15e49be719 Extracted ProcessorPipeline
Pulled some functionality out of _ImageSpecMixin into the ProcessorPipeline
class so it could be used independently of the model-related stuff.
2011-09-23 19:12:04 -04:00
Matthew Tretter
e190e78df5 Rename fields module to models. 2011-09-23 18:06:28 -04:00
Matthew Tretter
3f7ca512af Extension argument to cache_to includes dot.
It seems that's how we do it in python world. Who am I to argue?
2011-09-23 12:44:53 -04:00
Eric Eldredge
77459eae73 Pared down the _post_save_handler.
The original handler implementation ported code from the old ImageModel's
save method, but ended up duplicating the efforts of the ImageSpecFile's
_create method.
2011-09-22 19:44:47 -04:00
Matthew Tretter
3d810e7be5 Rename ImageSpecFile properties
`_obj` and `_spec` are now `instance` and `field`, to match FieldFile.
2011-09-22 18:13:32 -04:00
Matthew Tretter
0ef56e1aaa process() accepts file
In the old IK API, processors (like `Transpose`) were able to access
the file by inspecting the model instance (which carried an options
object that specified the attribute name of the ImageField from which
the file could be extracted). Since the new API allows for multiple
ImageFields (and because IKOptions have been removed), it became
necessary to provide more information. Initially, this was accomplished
by passing the spec to `process()`, however with the addition of
ProcessedImageField, it became clear the a cleaner solution was to pass
only the field file (ImageSpecFile or ProcessedImageFieldFile).

This keeps the ORM stuff (fields, etc.) out of the `ImageProcessor` API
but (because field files, not just regular files, are passed) the
average hacker can still have their processor make use of model
information by accessing the model through the file's `instance`
property.
2011-09-22 17:58:33 -04:00
Matthew Tretter
bd7eb7284b BoundImageSpec is now ImageSpecFile
In preparation for unifying the ImageSpecFile and
ProcessedImageFieldFile interfaces.
2011-09-22 09:20:37 -04:00
Matthew Tretter
5718c304cf ProcessedImageField replaces preprocessor_spec 2011-09-22 00:24:13 -04:00
Matthew Tretter
98a5ca32b4 Fix bug when imgfield doesn't exist. 2011-09-21 23:10:06 -04:00
Matthew Tretter
a60dfba31d IKOptions no longer exists. 2011-09-21 21:15:16 -04:00
Matthew Tretter
788257b819 property_name is now attname
That's what Django calls it; that's what we'll call it.
2011-09-21 21:15:16 -04:00
Matthew Tretter
fb53981ec8 No need to extend ImageModel.
In fact, ImageModel doesn't exist anymore. Most of IKOptions have also been
removed.
2011-09-21 21:15:09 -04:00
Matthew Tretter
7167016237 Removed specs list from opts. 2011-09-21 20:21:48 -04:00
Matthew Tretter
305d20569c Moved get_bound_specs to utils. 2011-09-21 20:17:23 -04:00
Matthew Tretter
4e23254e73 Crop processor accepts anchor argument. 2011-09-21 19:02:18 -04:00
Matthew Tretter
e4c4fe02b3 Separated Crop.process() and Fit.process()
They didn't have enough in common to warrant them being branches of the
same method.
2011-09-21 18:24:02 -04:00
Matthew Tretter
b5616d2f75 Move ImageSpec to fields module. 2011-09-21 11:37:29 -04:00
Eric Eldredge
fe2fb844af Changed the way post_save and post_delete signals are being handled.
One handler is created per model instead of per bound image spec.
This cuts down on the number of handlers created, and also offloads the
policing of the handlers in memory to the signal framework. Since they are no
longer being created per spec, the handlers can be weakly referenced.
2011-09-21 10:44:05 -04:00
Eric Eldredge
b1c5432310 Implemented post_save and post_delete handlers for ImageSpecs.
Removed the save and clear_cache methods from ImageModel (along with helpers).
Now, whenever an ImageSpec is contributed to a model, handlers are created for
the post_save and post_delete signals. The post_save handler does the work of
running the ImageSpec processors and caching the resulting file, while the
post_delete handler does the work cleaning up the cached files.
2011-09-21 09:56:27 -04:00
Matthew Tretter
34e475885b Unbound fields are accessible from class. 2011-09-21 09:52:38 -04:00
Matthew Tretter
2770be23ea Naming & implementation of bound fields are more consistent.
Bound fields are now named as such (BoundBlah), extend their unbound
counterparts, and their constructors accept an unbound instance.
2011-09-21 09:39:06 -04:00
Matthew Tretter
a71b3ca337 Removed Format processor
The Format processor was really a special case and didn't do any
processing at all. Instead, ImageSpec just knew to look for it and
responded accordingly. Therefore, it's been replaced with a `format`
property on ImageSpec. This warranted a deeper look at how the format
and extension were being deduced (when not explicitly provided); the
results are documented in-code, though the goal was "no surprises."
2011-09-20 21:34:00 -04:00
Matthew Tretter
80c785f2e5 No need for this. 2011-09-20 21:03:34 -04:00
Matthew Tretter
544d5b874a Added AdminThumbnailView field.
You're no longer restricted to just one, special-case admin thumbnail. Make as
many as you want by adding AdminThumbnailView properties to your model and
including them in your admin class's `list_display` tuple. You can also provide
a custom template. Note that (because this change introduces templates to
imagekit), imagekit is now required in INSTALLED_APPS.

Ideally we could get this stuff out of the model, but we'll have to look into
whether that's possible without making things really complicated.
2011-09-20 19:37:04 -04:00
Matthew Tretter
501d3c7ad3 Now using contribute_to_class.
By creating the Descriptor using contribute_to_class (instead of in
ImageModelBase's __init__), we take the first step towards eliminating the need
to extend ImageModel at all.
2011-09-20 15:44:54 -04:00
Matthew Tretter
82348d4931 Changed how cache files are named.
Removed the cache_dir, cache_filename_fields and cache_filename_format
properties of IKOptions. While these were very powerful, I felt that it was
unnecessarily confusing to have two properties (cache_dir and
cache_filename_format) that determine the filename. The new cache_to property is
modeled after ImageField's upload_to and behaves almost identically (the only
exception being that a callable value receives different arguments). In
addition, I felt that the interpolation of model properties provided by
cache_filename_fields, though useful, would be better handled by a utility
function outside of this library.
2011-09-18 21:08:49 -04:00
Bryan Veloso
df93146049 Making versioning a little easier on myself. 2011-09-12 14:17:12 -07:00
unknown
e295c9c039 error fix: https://github.com/jdriscoll/django-imagekit/issues/25 2011-09-12 17:43:53 +08:00
Matthew Tretter
8cfe485a5a Storage can be specified on a per-spec basis.
If not defined on the spec, IKOptions.default_storage will be used. If that's
not defined, it will fall back to the image field's storage.
2011-09-10 00:25:34 -04:00
Matthew Tretter
57a28091c5 Added default_image_field
This works kind of like Django's models' _default_manager. If your specs don't
specify an image_field, and your IKOptions don't specify a default_image_field,
the first ImageField your model defines will be used.
2011-09-10 00:25:27 -04:00
Matthew Tretter
4c78f2d24c _imgfield is now a property of ImageSpec
Moved _imgfield from ImageModel to ImageSpec. Theoretically, this will allow you
to have specs that use different image fields on the same model.
2011-09-10 00:24:37 -04:00
Matthew Tretter
5e00de5204 Admin thumbnails. 2011-09-10 00:23:47 -04:00
Bryan Veloso
9af96b4098 Creating a dedicated tests directory.
Moves tests.py out of the main module. Still a work in progress.
2011-09-09 16:33:42 -07:00
Matthew Tretter
a1f11facbe Processors now use static properties. 2011-09-08 16:49:44 -04:00
Matthew Tretter
db4d704f71 Changed ImageSpec constructor so you can use static properties.
For example:

    class MyImageSpec(ImageSpec):
        quality = 100

    class Photo(ImageModel):
        display = MyImageSpec()
2011-09-08 16:48:53 -04:00
Matthew Tretter
def8dea23f Storage moved onto ImageSpec. 2011-09-08 10:28:54 -04:00
Matthew Tretter
e32ccb617d Resize split into Crop and Fit. 2011-09-08 10:28:54 -04:00
Matthew Tretter
cd3395b68f Processors are now instance-based. 2011-09-08 10:28:50 -04:00
Matthew Tretter
a9895f335a Using spec properties from ImageModel. 2011-09-08 10:00:22 -04:00
Bryan Veloso
7cb59c7351 Think it's time to bump to 0.4.0. 2011-09-07 15:52:14 -07:00
Matthew Tretter
2387cc4be2 Added ability to specify specs in IKOptions directly. 2011-09-02 23:35:58 -04:00
Markus Kaiserswerth
3e3302c7f7 Improve fault tolerance of Accessor._delete()
Handle/ ignored NotImplementedError and IOError which might get thrown
by the storage backend on delete.
2011-08-26 16:42:14 +02:00
BaBaBags
db95e63a63 Added support for preserving transparency when converting from color to greyscale 2011-08-23 10:20:37 -04:00
Bers
aa348d76f6 fix issue #12 2011-07-04 04:09:31 -07:00
Josh Ourisman
5976a512e6 allowing any fields on the object to be specified for use in naming of generated images; default to allowing pk 2011-06-28 14:27:47 -04:00
Josh Ourisman
9845befd96 Added the pk of the object into the dictionary of values passed to the string formatting for cache_filename. 2011-06-28 11:08:05 -07:00
Shanto
6b1aff64c2 Fixes: CMYK files from Photoshop fails to load with exception -2 2011-06-17 13:13:20 -07:00
Bryan Veloso
9637a43551 Bumping the verison numbers. 2011-04-01 11:56:44 -07:00
Bryan Veloso
f777c08b17 Whitespacing. 2011-03-26 00:46:17 -07:00
Jonathan Slenders
57ef4748b9 fixed 'sender' not defined bug (2) 2011-03-26 15:40:22 +08:00
Jonathan Slenders
53cddf7752 fixed 'sender' not defined bug 2011-03-26 15:40:21 +08:00
Bryan Veloso
ad3f15ef76 Instead of overriding Model.delete(), we'll connect a public clear_cache() method to a post_delete() signal so that bulk actions clean props as well. 2011-02-23 12:54:09 -08:00
Bryan Veloso
1b29437180 Bumping the version number. 2011-02-12 14:04:42 -08:00
Bryan Veloso
c566378764 Accessor._delete() and Accessor._exists() needed conditionalizing as well. ikflush was yelling at me. 2011-02-13 05:52:07 +08:00
Bryan Veloso
5d0808467e Bumping internal version to 0.3.4. 2011-02-11 12:52:42 -08:00
Greg Newman
2b80ccf2e3 patch applied badly, fixing if 2011-02-12 04:12:37 +08:00
Greg Newman
34a2640cf5 if the ImageField is null and not required, don't create 2011-02-12 04:06:19 +08:00
Bryan Veloso
5d1c898283 Flush newer records first. Also, spacing. 2011-02-10 19:00:35 -08:00
Bryan Veloso
90dab6c8a1 Don't pre_cache if we don't have an image. 2011-02-10 16:56:31 -08:00
Bryan Veloso
ea35379fd2 Don't create the image if spec.pre_cache is True. 2011-02-10 16:23:36 -08:00
Justin Driscoll
7076e520f7 Fixed type 2010-06-12 15:05:31 -04:00
Justin Driscoll
93a71c4c60 Merged changes 2010-06-12 15:04:43 -04:00
Justin Driscoll
ec83074cee ImageKit should now support optional imagefields better now. 2010-06-12 15:03:59 -04:00
Justin Driscoll
d588be8b8a Bumped version number 2010-04-26 10:40:24 -04:00
Justin Driscoll
4ce59d3e31 Reverted changes to cache path that could possible cause filename collisions 2010-04-22 16:39:51 -04:00
Justin Driscoll
02019f7263 Imagekit not longer uses the appends the upload_to path of the image when generating the cache filename. The new default format is [media_root]/[cache_dir]/[cache_filename]. 2010-01-25 16:19:29 -05:00
Justin Driscoll
125c2c1470 Cleaned up trailing whitespace 2009-12-19 11:01:54 -05:00
Ben Jackson
26f01721df Add IKOption.storage to explicitly set cached thumbnail storage.
Original image storage is still the default, and the original image
is always read from its own storage.
2009-12-17 22:26:19 -08:00
Justin Driscoll
f28683dd0f Fixed indentation error 2009-09-14 14:51:29 -04:00
Justin Driscoll
fa6659162c Added 'replace' argument to save_image 2009-09-02 14:26:30 -04:00
Justin Driscoll
ae14d137de Added tests for save_image method 2009-09-02 14:20:43 -04:00
Justin Driscoll
bc4ff39e9e Added save_image method to ImageModel 2009-09-02 14:20:30 -04:00
Justin Driscoll
77e953edcb Escaped urls in admin_thumbnail 2009-08-31 17:00:38 -04:00
Justin Driscoll
48a2035665 Merged changes 2009-08-11 17:59:03 -04:00
Justin Driscoll
2e0530bb50 Added support for functions in cache_dir 2009-08-11 17:58:22 -04:00
Justin Driscoll
1d82a64bd7 Fixed indent and refactored ikflush command (issue #19) 2009-08-10 14:30:41 -04:00
Justin Driscoll
eb97ed1180 spec.name now respects the upload_to path and added additional error handling to Transpose:auto 2009-07-19 15:26:53 -04:00
Justin Driscoll
68b8d46a2f Added 'auto' method to Transpose processor 2009-07-19 15:04:43 -04:00
Justin Driscoll
7a04da81e1 Updated preprocessor implementation 2009-07-19 13:50:31 -04:00
Justin Driscoll
510d4fc1df IOErrors now pass silently when generating spec images 2009-07-09 14:42:49 -04:00
Justin Driscoll
70acfa5a95 Bumped version number 2009-06-04 11:58:33 -04:00
Justin Driscoll
70da53ba4d Added format processor to force a format/extension change 2009-06-04 11:47:16 -04:00
Justin Driscoll
81f4b950cd Restored defaults 2009-06-04 11:06:40 -04:00
Justin Driscoll
47e087e3b4 Fixed handling of palleted images 2009-06-04 11:06:11 -04:00
Justin Driscoll
1a7ec0d947 Bumped version to 0.3.1 for release 2009-05-17 08:46:08 -04:00
Justin Driscoll
62fc447dcc Bumped version in __init__.py 2009-05-17 08:43:06 -04:00
Justin Driscoll
486f602aa2 Merged changes 2009-04-19 13:50:34 -04:00
Justin Driscoll
9c455a19c5 Fixed a couple issues with having an optional (and empty) image field in an ImageModel 2009-04-19 13:46:01 -04:00
Justin Driscoll
cc5c846c0a Fixed check in admin_thumbnail_view 2009-03-13 13:14:53 -04:00
Justin Driscoll
e03edf8e83 admin_thumbnail_view no longer crashes when there is no file found 2009-03-13 12:35:33 -04:00
Justin Driscoll
e0a2ad9ede Added crop choice tuples and tweaked a couple of comments 2009-03-03 11:44:51 -05:00
Justin Driscoll
82bd312baf Renamed config to defaults and modified a couple of default options 2009-02-26 09:59:05 -05:00
Justin Driscoll
54903c7e77 Updated version number and setup requirements 2009-02-04 17:28:30 -05:00
Justin Driscoll
a0cd5c5774 Wrapped opened file in StringIO 2009-02-04 14:38:30 -05:00
Justin Driscoll
45f4c954f0 Added a check to remove any wrappers from the file like object returned in storage.open() 2009-02-04 14:23:52 -05:00
Justin Driscoll
e1e2b52daa Removed dependance on storage.path() which may not be implemented by storage classes 2009-02-04 13:49:20 -05:00
Justin Driscoll
c1777cec90 Fixed tests 2009-02-03 08:50:54 -05:00
Ariel Nunez
920bf47128 Added setup.py and relocated source dir 2009-02-02 15:46:41 -05:00