pgmagick is a convenient package for processing images with python. It seems to wrap an image processing tool called GraphicsMagick. (It seems to work with ImageMagick, but I haven't tried it.)
The environment is
is
$ brew install graphicsmagick # or imagemagick
$ brew install boost --with-thread-unsafe --build-from-source
$ pip install pgmagick
I could install it above, but I couldn't install it successfully.
Check with the brew doctor to see if homebrew is out of order.
When you run pip install pgmagick,
clang: error: unknown argument: '-mno-fused-madd
Error was displayed and the installation could not be completed successfully.
I tried setting the environment variable because it works when I set the environment variable, but it didn't work either, so I installed it with the help of stackoverflow.
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pgmagick
clang error: unknown argument: '-mno-fused-madd' (python package installation failure)
brew install boost --with-thread-unsafe --build-from-source The command takes a lot of time, so it takes about 35 minutes </ strong>.
>>> from pgmagick import gminfo
>>> gminfo.library
'GraphicsMagick' # or 'ImageMagick'
>>> gminfo.version
'1.3.x'
>>>
OK if the version etc. is displayed.
sample
>>> from pgmagick import Image, FilterTypes
>>> im = Image('input.jpg')
>>> im.quality(100)
>>> im.filterType(FilterTypes.SincFilter)
>>> im.scale('100x100')
>>> im.sharpen(1.0)
>>> im.write('output.jpg')
Reduces the images on the folder to 100px (either vertically or horizontally longer).
Sample image reduced to 100px.
There are many image-related items, but they are relatively easy and convenient, so please give them a try.
Recommended Posts