Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace VB Script Image Cropper with a Python Alternative #20

Open
CodyBerenson opened this issue May 3, 2020 · 17 comments
Open

Replace VB Script Image Cropper with a Python Alternative #20

CodyBerenson opened this issue May 3, 2020 · 17 comments
Labels
enhancement New feature or request

Comments

@CodyBerenson
Copy link
Owner

@JPH71
When the thumbor instance is unavailable, the Scene Agents will fire off a VB script which crops poster images. It is a terrific solution and works perfectly....as long as you are on a windows platform.

Please consider replacing the VB script functionality with a Python Alternative, if feasible, so that the solution is platform agnostic.

Hopefully @acvigue is able to identify the issue with the thumbor instance for those folks not on a Windows platform.

@CodyBerenson CodyBerenson added the enhancement New feature or request label May 3, 2020
@JPH71
Copy link

JPH71 commented May 16, 2020

@j-ktz
I may need your help to test the cropper on MAC OS since you use a Macintosh.
For MACS I may opt to write an applescript program to do the cropping, let me investigate this first...

Cheers

Jason

@j-ktz
Copy link

j-ktz commented May 16, 2020 via email

@JPH71
Copy link

JPH71 commented May 16, 2020 via email

@CodyBerenson
Copy link
Owner Author

@JPH71 why are you not watching ESC? Bad boy.

@JPH71
Copy link

JPH71 commented May 16, 2020 via email

@CodyBerenson
Copy link
Owner Author

Sacrilegious. Two Hail Johnny Logans and three Our ABBAs.

@JPH71
Copy link

JPH71 commented May 17, 2020 via email

@CodyBerenson
Copy link
Owner Author

@JPH71
Update: The google cloud platform the Thumbor instance is currently hosted on expires in 70 days. From a prioritization of workload perspective, please enable an alternative to Thumbor by then.

@JPH71
Copy link

JPH71 commented Feb 22, 2021 via email

@udmada
Copy link

udmada commented Jan 8, 2022

double posting as I've commented on @codeanator's fork:

Thanks for all your effort first of all! Not sure how you or the original author implemented this Thumbor service, but from what I saw, it seems to me that this Thumbor is living on a Python/Tornado server. Processing image is a particular use case for taking a more serverless approach, given that most of the time, image processing is handled on the fly. Practically, there is no need to actually host a server (aka low utilisation rates). What I would suggest is that maybe we can look into a solution such as this: https://github.com/aws-solutions/serverless-image-handler

AWS or GCP or Azure doesn't necessarily matter I guess. It will bring down the overall operational cost and provide a more scalable and reliable solution.

@CodyBerenson
Copy link
Owner Author

@dulinnan Hi there, thanks for the suggestion. I’ll look more into when I return home from holiday in Spain. One note though: there is no current operational cost because we use GCP’s free-trial service and just initiate a new one when it expires.It isn’t elegant because we quarterly have to update the thumbor address. I'm ok personally paying GCP a nominal amount to keep a stable image processing service that is available to all, but as you note Thumbor would cost me about $30/month which wont do (hence our current free-trial solution). So, Im looking forward to digging into your suggestion. ¡Gracias!

@udmada
Copy link

udmada commented Jan 12, 2022

Hi @CodyBerenson Hope you are having a wonderful time in Spain! Greetings from New Zealand Aotearoa!
Sorry I didn't know you are putting your own money into this project. I appreciate it a lot and at the same time, I don't think it is fair for you to do this for all of us.

Being cost-conscious myself, I have leaned towards a more serverless approach for my personal projects. Matter of fact, I just built a simple serverless worker that resizes a given image based on this repo : https://image-worker.udmada.workers.dev/poster.png?mode=limit&width=200&height=300&origin=https://pic.aebn.net/dis/i/Stream/Movie/BoxCovers/a272364_xlf.jpg
that is completely free. Plus by utilising Cloudflare's global CDN, we can facilitate the whole image fetch-then-crop process.

@CodyBerenson
Copy link
Owner Author

@dulinnan
Hi, Finally back from Spain and jetlagged as hell! I'm not very cloud savvy....but I don't see how the serverless approach can be implemented without a cloud provider account and therefore a monthly fee. Therefore, serverless or thumbor, we're still limited to the 90 day free trial accounts. Am I missing something?

@udmada
Copy link

udmada commented Feb 2, 2022 via email

@udmada
Copy link

udmada commented Nov 10, 2022

Would this work somewhat?

if os.name == 'posix':
    file_extension = picInfo.format
    log('UTILS :: Using Python Pillow to crop image to: {0} x {1}'.format(desiredWidth, desiredHeight))
    remote_pic = Image.open(BytesIO(picContent))
    cropped_pic = remote_pic.crop(((width - cropWidth) // 2,
                              (height - cropHeight) // 2,
                              (width + cropWidth) // 2,
                              (height + cropHeight) // 2))
    img_byte_arr = BytesIO()
    cropped_pic.save(img_byte_arr, format=file_extension)
    picContent = img_byte_arr.getvalue()

Not a python person XD

@JPH71
Copy link

JPH71 commented Nov 10, 2022 via email

@JPH71
Copy link

JPH71 commented Dec 29, 2022

Darned it - it does not work within plex....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants