PGMA-Modernized icon indicating copy to clipboard operation
PGMA-Modernized copied to clipboard

Replace VB Script Image Cropper with a Python Alternative

Open CodyBerenson opened this issue 4 years ago • 17 comments

@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 avatar May 03 '20 16:05 CodyBerenson

@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

JPH71 avatar May 16 '20 14:05 JPH71

Happy to help! Just let me know :)

Sent from my iPhone

On May 16, 2020, at 10:39 AM, JPH71 [email protected] wrote:

 @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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

j-ktz avatar May 16 '20 14:05 j-ktz

brilliant!

On Sat, 16 May 2020 at 15:47, j-ktz [email protected] wrote:

Happy to help! Just let me know :)

Sent from my iPhone

On May 16, 2020, at 10:39 AM, JPH71 [email protected] wrote:

 @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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CodyBerenson/PGMA-Modernized/issues/20#issuecomment-629657373, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKI3AKKTDTKUBPNQ3VU6S33RR2RQTANCNFSM4MYGAWLA .

JPH71 avatar May 16 '20 14:05 JPH71

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

CodyBerenson avatar May 16 '20 19:05 CodyBerenson

It's just a repeat of the old stuff...

On Sat, 16 May 2020, 20:19 CodyBerenson, [email protected] wrote:

@JPH71 https://github.com/JPH71 why are you not watching ESC? Bad boy.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CodyBerenson/PGMA-Modernized/issues/20#issuecomment-629693980, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKI3AKOVTUGFPBUNDFFUBCTRR3RK3ANCNFSM4MYGAWLA .

JPH71 avatar May 16 '20 20:05 JPH71

Sacrilegious. Two Hail Johnny Logans and three Our ABBAs.

CodyBerenson avatar May 16 '20 23:05 CodyBerenson

Lol... Good one I managed to write another scrapper though for gay-movie.org... Just got to test it first.

On Sun, 17 May 2020, 00:18 CodyBerenson, [email protected] wrote:

Sacrilegious. Two Hail Johnny Logans and three Our ABBAs.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CodyBerenson/PGMA-Modernized/issues/20#issuecomment-629718450, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKI3AKP4LRWFYKCSM2HECPTRR4NOFANCNFSM4MYGAWLA .

JPH71 avatar May 17 '20 00:05 JPH71

@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.

CodyBerenson avatar Feb 22 '21 16:02 CodyBerenson

I will do my best!

On Mon, 22 Feb 2021 at 16:03, Cody Berenson [email protected] wrote:

@JPH71 https://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CodyBerenson/PGMA-Modernized/issues/20#issuecomment-783480575, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKI3AKN2XPN2TWV3AVRRZQDTAJ547ANCNFSM4MYGAWLA .

JPH71 avatar Feb 22 '21 17:02 JPH71

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.

udmada avatar Jan 08 '22 00:01 udmada

@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!

CodyBerenson avatar Jan 09 '22 18:01 CodyBerenson

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.

udmada avatar Jan 12 '22 07:01 udmada

@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?

CodyBerenson avatar Feb 02 '22 20:02 CodyBerenson

Hi! Thanks for the reply! And rest up!

As for the cloud provider, yes normally you do need an account and some fees do occur but the way how I implemented the worker in my previous comment requires only an account but zero fees as the free quotes is good enough for this small community.

On Thu, 3 Feb 2022 at 09:25, Cody Berenson @.***> wrote:

@dulinnan https://github.com/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?

— Reply to this email directly, view it on GitHub https://github.com/CodyBerenson/PGMA-Modernized/issues/20#issuecomment-1028327414, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABS4NGUIC6X3NUGCH4IZ6PDUZGHMRANCNFSM4MYGAWLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

udmada avatar Feb 02 '22 21:02 udmada

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

udmada avatar Nov 10 '22 11:11 udmada

oooh i am going to try this tonight.... I can then get rid of the vbscript! thank you....

On Thu, 10 Nov 2022 at 12:27, Adam @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/CodyBerenson/PGMA-Modernized/issues/20#issuecomment-1310142437, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKI3AKOORKUXWSCHNLXQQTDWHTL35ANCNFSM4MYGAWLA . You are receiving this because you were mentioned.Message ID: @.***>

JPH71 avatar Nov 10 '22 13:11 JPH71

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

JPH71 avatar Dec 29 '22 00:12 JPH71