ImageMagick not converting JPEGs - imagemagick

I had a problem with ImageMagick not converting JPEGs on a fresh install of Mac OSX Lion. I was getting the fallowing error:
convert: unable to open module file `/Users/natewade/.magick/jpeg.la': No such file or directory # warning/module.c/GetMagickModulePath/813.
convert: no decode delegate for this image format `test1.jpg' # error/constitute.c/ReadImage/544.
convert: no images defined `test1.jpg' # error/convert.c/ConvertImageCommand/3044.
However conversions with gifs and other formats worked fine. After Googling around I came across many people with the same problem online from as far back as 2006. But none of them had posted a solutions.
When you configured Image magic you may notice this:
checking for JPEG...
checking jconfig.h usability... no
checking jconfig.h presence... no
checking for jconfig.h... no
checking jerror.h usability... no
checking jerror.h presence... no
checking for jerror.h... no
checking jmorecfg.h usability... no
checking jmorecfg.h presence... no
checking for jmorecfg.h... no
checking jpeglib.h usability... no
checking jpeglib.h presence... no
checking for jpeglib.h... no
checking for jpeg_read_header in -ljpeg... no
checking for JPEG library is version 6b or later... no
checking if JPEG package is complete... no

This problem has been solved. This error was on Mac OSX 10.7.3, but after Googling the problem I have found the same problem posted by other versions of OSX as well as other operating systems (seems like CentOS the most). The same fix should apply to other Linux flavors as well.
The problem was quite simple to fix. All you need to do is install Libjpeg:
curl -O http://www.ijg.org/files/jpegsrc.v8c.tar.gz
$ tar zxvf jpegsrc.v8c.tar.gz
$ cd jpeg-8c/
$ ./configure
$ make
$ sudo make install
Reinstall ImageMagick and you should be good to go.

had to install ghostscript - so for mac
brew install ghostscript
brew link --overwrite ghostscript
brew reinstall imagemagick --build-from-source

You need to have specific header files of JPEG library,
in other words to have installed several *-devel packages like libjpeg-turbo-devel, openjpeg-devel. The same for another image formats like PNG, TIFF, WMF and so on (libpng-devel, libtiff-devel, libwmf-devel, ghostscript-devel, etc).

Related

"fftw.h not found" after installing it in Mac terminal

I'm running problem of getting fftw working. I'm on mac and have installed fftw using brew on the terminal.
brew install fftw
It gave me a reminder of "Warning: fftw 3.3.8 is already installed and up-to-date" if I put in this install command again. But I cannot call fftw.h in C. It gave me an error of "fftw.h file not found" if I have a line of
#include <fftw.h>
I also tried installing directly by
./configure
make
make install
and ran
make check
It told me "FFTW transforms passed basic tests!", but it still didn't work in C.
Any suggestions would be appreciated!
You need to specify the location of the header to your compiler. Adding the directory inclusion for either installation in both cases the header can be found in /usr/local/include
gcc ... -I/usr/local/include ...
Additionally, as has been pointed out, you need to #include <fftw3.h>. Also be reminded, that your autoconf build only has the double precision functionality installed. While the brew installation brings all 3 precisions, float, double and long double.
You will hit a wall again, possibly, when you want to link. Add -L/usr/local/lib to the linker command to be able to link like so -lfftw3 -lfftw3f -lfftw3l etc

Bash: How to get size of image compressed with JPEG2000

I encoded image with jPEG2000 standard, how to get size of image after compression.
identify inputimage.pgm
works but
identify inputimage.jpc
does not work.
error is "identify: no decode delegate for this image format `J2K' # error/constitute.c/ReadImage/501."
Error messages says identify did not find necessary library to handle JPEG2000. You can check output of identify -list format to confirm that.
Indeed, it seems that JPEG2000 support is not enable in last versions of Ubuntu. Debian fixed this issue a while ago. So I suggest:
Install another distribution (Debian for exemple)
Rebuild imagemagick package with support for JPEG2000
Under Ubuntu, you can rebuild ImageMagick with JPEG2000 support following these steps:
apt-get source imagemagick
sudo apt-get build-dep imagemagick
sudo apt-get install libopenjp2-7-dev
dpkg-buildpackage -uc -us
sudo dpkg -i *deb
You can test which image formats your ImageMagick installation is able to read/write by running:
identify -list format
And further, which files ImageMagick is able to read/write by "delegating" out to a "helper program", by running:
identify -list delegate
If you are on Linux and missing JPEG2000, you will probably need to have installed the following before running ./configure to configure ImageMagick:
pkg-config
libopenjpeg
libopenjp2-7-dev
On a Mac under macOS at least, that means you need to have done:
brew install openjpeg
brew install imagemagick --with-openjpeg # Use "reinstall" if already installed
If ImageMagick does not the trick, you can try using exiftool:
exiftool -FileSize inputimage.jpc

How to tell ImageMagick's configure where to find Libpng and Zlib?

I was going through this old post Compile ImageMagick from source with PNG support on OSX.
I did mostly all of what it says with minor changes. Libpng and Zlib are in the following paths
/usr/local/libpng
/usr/local/zlib
When trying to configure ImageMagick 7.0.5-7 I do it like
./configure --prefix=/usr/local/imagemagick
CPPFLAGS='-I/usr/local/libpng/include -I/usr/local/zlib/include'
LDFLAGS='-L/usr/local/libpng/lib -L/usr/local/zlib/lib'
--enable-shared --enable-delegate-build
But still png and zlib are marked as
ZLIB --with-zlib=yes no
PNG --with-png=yes no
In some other website I read that I should add to the system variable PKG_CONFIG_PATH the path to the .pc files. So before running configure I tried also
export PKG_CONFIG_PATH=/usr/local/libpng/lib/pkgconfig:/usr/local/zlib/share/pkgconfig/
but still the libraries are not recognized.
Anyone around that knows how to tell the configure script where to look for the libraries?
I got it working !
After exploring the configure file I figured out that what was missing was pkg-config tool.
I just download it from this site installed it.
Run the command above and it works fine now.

I've already installed binutils in osx 10.11, but objdump still doesn't work

I've tried hard to install binutil with HomeBrew onto osx 10.11, finally succeed, but objdump still doesn't work. The response given by terminal is as follow:
MacBook-Pro:~ Mars$ brew install binutils
==> Downloading https://homebrew.bintray.com/bottles/binutils-2.26.el_capitan.bo
Already downloaded: /Library/Caches/Homebrew/binutils-2.26.el_capitan.bottle.tar.gz
==> Pouring binutils-2.26.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/binutils/2.26: 109 files, 140.3M
MacBook-Pro:~ Mars$ objdump
-bash: objdump: command not found
Anybody can help?
To avoid conflicts with the utilities distributed by Apple, the binutils executables installed by Homebrew all have "g" prefixed to their names (so, for instance, objdump becomes gobjdump).
you need to update your $PATH to include the homebrew install location. you probably want to look at other places people have asked this question like:
https://superuser.com/questions/324616/how-should-i-set-the-path-variable-on-my-mac-so-the-hombrew-installed-tools-are

Xcode 5 llvm-g++ and llvm-gcc path?

I'm building an app for iOS7 with Xcode 5 using Google Tesseract OCR:
http://lois.di-qual.net/blog/install-and-use-tesseract-on-ios-with-tesseract-ios/
It worked fine with English recognition but I couldn't add any other language to the project. Then I found some other projects do it successfully by compiling Tesseract library:
http://inspirationteam.weebly.com/home/compile-use-tesseract-ocr-lib-301-on-ios
http://tinsuke.wordpress.com/2011/11/01/how-to-compile-and-use-tesseract-3-01-on-ios-sdk-5/
According to these articles, my llvm-g++ and llvm-gcc should be in
export CXX="$DEVROOT/usr/bin/llvm-g++"
export CC="$DEVROOT/usr/bin/llvm-gcc"
With $DEVROOT should be something like
export DEVROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
While I'm using Xcode 5 and Mac OSX 9.2 (I've heard that there're somethings had changed about C compiler with these guys), these paths didn't work for me:
checking build system type... i386-apple-darwin13.3.0
checking host system type... i386-apple-darwin13.3.0
checking how to print strings... printf
checking for gcc... /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc
checking whether the C compiler works... no
configure: error: in `/Users/phuoc-de/Desktop/a/leptonica-1.71':
configure: error: C compiler cannot create executables
See `config.log' for more details
I've already installed Command line, but it still didn't work.
Does anyone know how to solve this problem? Thanks.
My days of using configure, autoconf and friends are at an end as I can pretty much find everything I want from Macports.
For me it's as simple as typing:
$ sudo port install tesseract
and going to make tea.
I found my answer here
export CXX=`xcrun -find c++`
export CC=`xcrun -find cc`
Hope it helps someone!

Resources