CodyBerenson / PGMA-Modernized

An updated approach for Plex Gay Media Adult Agents for both Full Feature Films and Scenes
MIT License
124 stars 46 forks source link

Replace VB Script Image Cropper with a Python Alternative #20

Open CodyBerenson opened 4 years ago

CodyBerenson commented 4 years ago

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

JPH71 commented 4 years ago

@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 commented 4 years ago

Happy to help! Just let me know :)

Sent from my iPhone

On May 16, 2020, at 10:39 AM, JPH71 notifications@github.com 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.

JPH71 commented 4 years ago

brilliant!

On Sat, 16 May 2020 at 15:47, j-ktz notifications@github.com wrote:

Happy to help! Just let me know :)

Sent from my iPhone

On May 16, 2020, at 10:39 AM, JPH71 notifications@github.com 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 .

CodyBerenson commented 4 years ago

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

JPH71 commented 4 years ago

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

On Sat, 16 May 2020, 20:19 CodyBerenson, notifications@github.com 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 .

CodyBerenson commented 4 years ago

Sacrilegious. Two Hail Johnny Logans and three Our ABBAs.

JPH71 commented 4 years ago

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, notifications@github.com 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 .

CodyBerenson commented 3 years ago

@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 commented 3 years ago

I will do my best!

On Mon, 22 Feb 2021 at 16:03, Cody Berenson notifications@github.com 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 .

udmada commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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