GithubHelp home page GithubHelp logo

Comments (6)

varnav avatar varnav commented on May 24, 2024

Did some debugging, here's what happening:

File "C:\src\optimize-images\optimize_images\img_optimize_jpg.py", line 80, in optimize_jpg
piexif.transplant(os.path.expanduser(task.src_path), tmp_buffer)
File "C:\src\optimize-images\venv\lib\site-packages\piexif_transplant.py", line 26, in transplant
if image[0:2] == b"\xff\xd8":
TypeError: '_io.BytesIO' object is not subscriptable

It seems that transplant wants real file as 2nd parameter, but gets BytesIO instead. At same time it seems that BytesIO can be used as a 3rd parameter.

from optimize-images.

victordomingos avatar victordomingos commented on May 24, 2024

Hi! Thanks for reporting this issue. It seems to be happening on piexif's side, but it needs to be investigated. Does it happen always, regardless of the image file being processed?

Can you please provide the output of optimize-images --version (please anonymise the file paths if necessary)?

from optimize-images.

varnav avatar varnav commented on May 24, 2024

Looks like here:

piexif.transplant(os.path.expanduser(task.src_path), tmp_buffer)

you're giving tmp_buffer that is BytesIO. But transplant wants path to actual file.

Always the same.

I'm using latest revision from this repo.

from optimize-images.

victordomingos avatar victordomingos commented on May 24, 2024

I understand. Thanks for the details. It should not be very complicated to fix, but I can't promise a date.
I will try to fix in a few days it if no one submits a pull request first.

from optimize-images.

varnav avatar varnav commented on May 24, 2024

You actually don't need piexif, Pillow can handle this:

Load all EXIF data:

exif = img.info['exif']

Save it:

img.save('P4072956_thumb.jpg', exif=exif)

from optimize-images.

YellowTech avatar YellowTech commented on May 24, 2024

pip install optimize-images==1.4 does not suffer from this problem

from optimize-images.

Related Issues (20)

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.