0

I am trying to perform .getvalue() operation on PIL image on AWS Lambda to extract the bytes of PIL Image but my byte string length is different when i perform this operation on Local Machine and Its different when i Perform it on AWS Lambda, below is code

if base64_message[0:4] == b'%PDF':
        

       
        images = convert_from_bytes(base64_message, dpi=120, poppler_path=poppler_path)
   
    
        img_byte_arr = io.BytesIO()
        for img_page in (images):
           
            img_page.save(img_byte_arr, format = "jpeg")
            break
        img_obj = img_byte_arr.getvalue()

**print(len(img_obj))**


        

Basically I am trying using pdf2image library to get image byte from pdf but length of the bytes are different on Local Machine and its Different on AWS lambda which impacting by futher operation.

for particular Image, length of Imagebyte on AWS Lambda is 122103 and for same image it's 122551 on Local Machine.

Solution - After making some research i figured out that this issue is happening due to Lambda Linux Environment and i developed my entire application on Windows Machine, so different operating system is the issue.

  • 1
    My guess is that you have different versions of the JPEG library on the two machines. You can check with `python3 -m PIL` – Mark Setchell Dec 07 '22 at 08:28
  • Thanks for your Suggestion, i checked my version its same on both lambda and local. But i figured out the issue, the issue is related to Lambda Linux Environment, i developed my entire application on Local Windows Machine that is the reason why there is difference in output whenever i try to extract Imagebyte from Pillow image on Lambda and on Local Windows Machine. – Rahul Pidkalwar Dec 07 '22 at 11:35

0 Answers0