Giter Club home page Giter Club logo

Comments (9)

yeole-rohan avatar yeole-rohan commented on June 18, 2024 1

@agusmakmun will push a demo app for this!

from django-image-optimizer.

agusmakmun avatar agusmakmun commented on June 18, 2024

@yeole-rohan currently we didn't support to crop the image by using axis.
for the fast response might this answer will help you (by using Pillow) https://stackoverflow.com/a/20361739/6396981

meanwhile, if you have any MR that related with this,
I'll be happy to support it as well.


for example:

from image_optimizer.fields import OptimizedImageField
from .yourpackage import custom_image_optimizer


class CustomOptimizedImageField(OptimizedImageField):
    """An ImageField that gets optimized on save() using tinyPNG."""

    def save_form_data(self, instance, data):
        """Remove the OptimizedNotOptimized object on clearing the image."""
        # Are we updating an image?
        updating_image = True if data and getattr(instance, self.name) != data else False

        if updating_image:
            data = custom_image_optimizer(...)

        super().save_form_data(instance, data)

from django-image-optimizer.

yeole-rohan avatar yeole-rohan commented on June 18, 2024

from django-image-optimizer.

yeole-rohan avatar yeole-rohan commented on June 18, 2024

from django-image-optimizer.

agusmakmun avatar agusmakmun commented on June 18, 2024

hello @yeole-rohan thank you for creating new MR, we appreciate about your nice contribution 🙌
can you please also provide an unitest for that as well?

from django-image-optimizer.

yeole-rohan avatar yeole-rohan commented on June 18, 2024

@agusmakmun I have created a demo app inside yours demo app.

This app defined basic upload and cropping of image through axis.

  • Its on developer to user cropping library and how to pass x,y from image to our function.
  • I personally suggest cropper.js for this.

let me know if changes required.
looking ahead to merge.

from django-image-optimizer.

agusmakmun avatar agusmakmun commented on June 18, 2024

hello @yeole-rohan, thank so much for your contribution, we have merged your PR: #7 to #8
and I have pushed to new tag as well, you can try:

pip install django-image-optimizer --upgrade

then;

from image_optimizer.utils import crop_image_on_axis

...

for more:

def crop_image_on_axis(image, width, height, x, y, extension):
"""
function to crop the image using axis (using Pillow).
:param `image` is image data, e.g from request.FILES['image']
:param `width` float width of image
:param `height` float height of image
:param `x` is float x axis
:param `y` is float y axis
:param `extension` is string, e.g: ".png"

from django-image-optimizer.

yeole-rohan avatar yeole-rohan commented on June 18, 2024

from django-image-optimizer.

agusmakmun avatar agusmakmun commented on June 18, 2024

yeah, that's fine. and really appreciate if you doing that. 🙌

from django-image-optimizer.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.