Klathmon / imagemin-webpack-plugin

Plugin to compress images with imagemin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto rotate jpeg base on Exif Orientation

wltnet opened this issue · comments

At the moment when using imagemin-webpack-plugin, all the Exif data removed.
Is it possible to have an option allow auto rotate jpeg base on Exif Orientation?

So it's not possible with this plugin alone, and it's not something that I would want to add as an option, but you can always do this yourself with a plugin and run it before this plugin runs so that this plugin will compress the image after it's rotated.

If you are only using Webpack 4+, you can get away with using the new API which is pretty simple to write plugins for, and you should be able to write a small plugin that parses out the image, rotates it based on EXIF data, and then "saves" it back to the assets array when you are done, then this plugin will optimize the image like nothing was different.

Take a look here for some info on how to create a plugin. You'll need to tap into a "hook" to get it to run, think of a hook as a point in the compilation process, so "before compile", and "after emit" (aka after save). This plugin runs on the "emit" phase, which is just before webpack saves the files to disk, so any event before that (or even using that same event but putting your plugin first in the array of plugins) will work.

See here for a list of hooks that webpack provides.

I'm going to close this, but feel free to ask any questions you might have and I'll try to answer them as I can!