Introduction
When I tried to use imgp which is a CLI tool for image processing in Python on macOS (M3), Installation of imgp failed as follows.
clang: warning: argument unused during compilation: '-msse4' [-Wunused-command-line-argument] src/libImaging/AlphaComposite.c:28:5: error: use of undeclared identifier '__m128i' __m128i mm_max_alpha = _mm_set1_epi32(255); ^ src/libImaging/AlphaComposite.c:29:5: error: use of undeclared identifier '__m128i' __m128i mm_max_alpha2 = _mm_set1_epi32(255 * 255); ^ src/libImaging/AlphaComposite.c:30:5: error: use of undeclared identifier '__m128i' __m128i mm_zero = _mm_setzero_si128(); ^ src/libImaging/AlphaComposite.c:31:5: error: use of undeclared identifier '__m128i' __m128i mm_half = _mm_set1_epi16(128); ^ src/libImaging/AlphaComposite.c:32:5: error: use of undeclared identifier '__m128i' __m128i mm_get_lo = _mm_set_epi8( ^ src/libImaging/AlphaComposite.c:34:5: error: use of undeclared identifier '__m128i' __m128i mm_get_hi = _mm_set_epi8( ^ src/libImaging/AlphaComposite.c:137:13: error: use of undeclared identifier '__m128i' __m128i mm_dst, mm_dst_lo, mm_dst_hi; ^ src/libImaging/AlphaComposite.c:138:13: error: use of undeclared identifier '__m128i' __m128i mm_src, mm_src_hi, mm_src_lo; ^ src/libImaging/AlphaComposite.c:139:13: error: use of undeclared identifier '__m128i' __m128i mm_dst_a, mm_src_a, mm_out_a, mm_blend; ^ src/libImaging/AlphaComposite.c:140:13: error: use of undeclared identifier '__m128i' __m128i mm_coef1, mm_coef2, mm_out_lo, mm_out_hi; ^ src/libImaging/AlphaComposite.c:143:13: error: use of undeclared identifier 'mm_dst' mm_dst = _mm_loadu_si128((__m128i *) &dst[x]); ^ src/libImaging/AlphaComposite.c:143:22: error: call to undeclared function '_mm_loadu_si128'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] mm_dst = _mm_loadu_si128((__m128i *) &dst[x]); ^ src/libImaging/AlphaComposite.c:143:48: error: expected expression mm_dst = _mm_loadu_si128((__m128i *) &dst[x]); ^ src/libImaging/AlphaComposite.c:143:39: error: use of undeclared identifier '__m128i' mm_dst = _mm_loadu_si128((__m128i *) &dst[x]); ^ src/libImaging/AlphaComposite.c:145:13: error: use of undeclared identifier 'mm_dst_lo' mm_dst_lo = _mm_unpacklo_epi8(mm_dst, mm_zero); ^ src/libImaging/AlphaComposite.c:145:25: error: call to undeclared function '_mm_unpacklo_epi8'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] mm_dst_lo = _mm_unpacklo_epi8(mm_dst, mm_zero); ^ src/libImaging/AlphaComposite.c:145:43: error: use of undeclared identifier 'mm_dst' mm_dst_lo = _mm_unpacklo_epi8(mm_dst, mm_zero); ^ src/libImaging/AlphaComposite.c:145:51: error: use of undeclared identifier 'mm_zero' mm_dst_lo = _mm_unpacklo_epi8(mm_dst, mm_zero); ^ src/libImaging/AlphaComposite.c:147:13: error: use of undeclared identifier 'mm_dst_hi' mm_dst_hi = _mm_unpackhi_epi8(mm_dst, mm_zero); ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. error: command '/usr/bin/clang' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pillow-simd Failed to build pillow-simd ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pillow-simd)
This error is a known issue as below.
https://github.com/uploadcare/pillow-simd/issues/43
Solution
Building on macOS (M3) is not supported, so that I tried to install imgp using Docker. The installation process is described below.
(1) Start docker container
docker run-v $PWD:/work --rm --platform linux/amd64 -it python:3.12-slim /bin/bash
(2) Install packages for building
apt update apt install build-essential zlib1g-dev libjpeg-dev
(3) Install imgp
pip install imgp
(4) Verify installed binary
root@cc0fa40c9237:~# imgp usage: imgp [-h] [-x res] [-o deg] [-a] [-c] [-e] [-f] [-H] [-i] [-k] [-m] [-M res] [-n] [-N] [-O] [-P] [-q N] [-r] [-s byte] [-w] [-d] [PATH ...] Resize, rotate JPEG and PNG images. positional arguments: PATH source file or dir [default: current dir] options: -h, --help show this help message and exit -x res, --res res output resolution in HxV or percentage -o deg, --rotate deg rotate clockwise by angle (in degrees) -a, --adapt adapt to resolution by orientation [default: off] -c, --convert convert PNG to JPG format [default: off] -e, --eraseexif erase exif metadata [default: off] -f, --force force to exact specified resolution [default: off] -H, --hidden include hidden (dot) files [default: off] -i, --includeimgp re-process _IMGP files. * RISKY: refer to docs -k, --keep skip (honors -c or --pr) images matching specified H or V or --res=100 [default: off] -m, --mute operate silently [default: informative] -M res, --minres res min resolution in HxV or percentage of --res to resize -n, --enlarge enlarge smaller images [default: off] -N, --nearest use nearest neighbour interpolation for PNG [default: antialias] -O, --optimize optimize the output images [default: off] -P, --progressive save JPEG images as progressive [default: off] -q N, --quality N quality factor (N=1-95, JPEG only) [default: 75] -r, --recurse process non-symbolic dirs recursively [default: off] -s byte, --size byte minimum size to process an image [default: 1024] -w, --overwrite overwrite source images [default: off] -d, --debug enable debug logs [default: off] Version 2.9 Copyright © 2016-2023 Arun Prakash Jana <engineerarun> License: GPLv3 Webpage: https://github.com/jarun/imgp </engineerarun>
Note
$ uname -a Darwin weizen.local 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:45:48 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T8122 arm64 $ docker -v Docker version 26.1.1, build 4cf5afa
The above is the detailed content of Use imgp on macOS with Docker. For more information, please follow other related articles on the PHP Chinese website!

TomergelistsinPython,youcanusethe operator,extendmethod,listcomprehension,oritertools.chain,eachwithspecificadvantages:1)The operatorissimplebutlessefficientforlargelists;2)extendismemory-efficientbutmodifiestheoriginallist;3)listcomprehensionoffersf

In Python 3, two lists can be connected through a variety of methods: 1) Use operator, which is suitable for small lists, but is inefficient for large lists; 2) Use extend method, which is suitable for large lists, with high memory efficiency, but will modify the original list; 3) Use * operator, which is suitable for merging multiple lists, without modifying the original list; 4) Use itertools.chain, which is suitable for large data sets, with high memory efficiency.

Using the join() method is the most efficient way to connect strings from lists in Python. 1) Use the join() method to be efficient and easy to read. 2) The cycle uses operators inefficiently for large lists. 3) The combination of list comprehension and join() is suitable for scenarios that require conversion. 4) The reduce() method is suitable for other types of reductions, but is inefficient for string concatenation. The complete sentence ends.

PythonexecutionistheprocessoftransformingPythoncodeintoexecutableinstructions.1)Theinterpreterreadsthecode,convertingitintobytecode,whichthePythonVirtualMachine(PVM)executes.2)TheGlobalInterpreterLock(GIL)managesthreadexecution,potentiallylimitingmul

Key features of Python include: 1. The syntax is concise and easy to understand, suitable for beginners; 2. Dynamic type system, improving development speed; 3. Rich standard library, supporting multiple tasks; 4. Strong community and ecosystem, providing extensive support; 5. Interpretation, suitable for scripting and rapid prototyping; 6. Multi-paradigm support, suitable for various programming styles.

Python is an interpreted language, but it also includes the compilation process. 1) Python code is first compiled into bytecode. 2) Bytecode is interpreted and executed by Python virtual machine. 3) This hybrid mechanism makes Python both flexible and efficient, but not as fast as a fully compiled language.

Useaforloopwheniteratingoverasequenceorforaspecificnumberoftimes;useawhileloopwhencontinuinguntilaconditionismet.Forloopsareidealforknownsequences,whilewhileloopssuitsituationswithundeterminediterations.

Pythonloopscanleadtoerrorslikeinfiniteloops,modifyinglistsduringiteration,off-by-oneerrors,zero-indexingissues,andnestedloopinefficiencies.Toavoidthese:1)Use'i


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor
