Source

django-thumbnail-works / src / thumbnail_works / fields.py

Diff from to

src/thumbnail_works/fields.py

         elif settings.THUMBNAILS_FORMAT == 'PNG':
             im.save(io, 'PNG')
         
-        #return ContentFile(io.getvalue())
-        return File(io)
+        return ContentFile(io.getvalue())
+        #return File(io)
     
     
 class Thumbnail:
         name: is the path on the filesystem of the original image
         """
         
+        
         # Before saving, resize the source image if a size has been set
-        new_content = copy.copy(content)
+        #content = copy.copy(content)
         img_obj = ImageObject()
-        im = img_obj.get_img_data_from_file(new_content)
-        image_processors.resize(im, self.field.resize_source)
-        image_processors.sharpen(im)
-        new_content = img_obj.get_file_for_img_data(im)
+        im = img_obj.get_img_data_from_file(content)
+        im = image_processors.resize(im, self.field.resize_source)
+        im = image_processors.sharpen(im)
+        content = img_obj.get_file_for_img_data(im)
         
-        super(EnhancedImageFieldFile, self).save(name, new_content, save)
+        
+        super(EnhancedImageFieldFile, self).save(name, content, save)
         
         # self.name has been re-set in the save() above
         # use self.name to generate the thumbnail filename
         
+        """
         # Generate thumbnails
         if self.field.thumbnails:
             for thumbnail_name, thumbnail_size in self.field.thumbnails.items():
                 path_saved = self.storage.save(name, content)
                 
                 # check if path == path_saved
+         """
                 
     def delete(self, save=True):
         source_path = copy.copy(self.name)
         super(EnhancedImageFieldFile, self).delete(save)
         
+        """
         # Delete thumbnails
         if self.field.thumbnails:
             for thumbnail_name, thumbnail_size in self.field.thumbnails.items():
                 path = get_thumbnail_path(source_path, thumbnail_name)
                 self.storage.delete(path)
                 
-      
+      """
 
 
 class EnhancedImageField(ImageField):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.