How to set up phpimagik in Mac OS X? - macos

Can anyone tell me simple step by step to set up phpimagick in OS X?

Yes, use homebrew. Go to the homebrew website and install it with the one line script there. - I don't want to paste it here because you need the latest and greatest line at the time of following these instructions.
Then, when you have homebrew installed, do these steps to get ImageMagick installed and running under PHP and also with Apache.
# Check all of homebrew is working - fix any errors before proceeding
brew doctor
# Get latest versions of everything if you already had "homebrew" installed
# Probably not necessary if you just installed "homebrew" in previous step
brew update && brew upgrade
# Find latest PHP version - using "brew search"
newestPHP=$(brew search php | grep -E "php[0-9]+$" | sort | tail -1)
echo $newestPHP
e.g. php56
# Install latest PHP and corresponding ImageMagick
brew install ${newestPHP} ${newestPHP}-imagick
e.g. brew install php56 php56-imagick
# Check that the installation worked - you MUST use "/usr/local/bin/php"
/usr/local/bin/php -i | grep -i imag
Output
Additional .ini files parsed => /usr/local/etc/php/5.6/conf.d/ext-imagick.ini
PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
imagick
imagick module => enabled
imagick module version => 3.1.2
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version => ImageMagick 6.9.1-1 Q16 x86_64 2015-04-15 http://www.imagemagick.org
ImageMagick copyright => Copyright (C) 1999-2015 ImageMagick Studio LLC
ImageMagick release date => 2015-04-15
ImageMagick number of supported formats: => 204
ImageMagick supported formats => 3FR, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DFONT, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, ERF, FAX, FITS, FRACTAL, FTS, G3, GIF, GIF87, GRADIENT, GRAY, GV, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, JNG, JNX, JPE, JPEG, JPG, JPS, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TILE, TIM, TTC, TTF, TXT, UBRL, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WMV, WPG, X3F, XBM, XC, XCF, XPM, XPS, XV, YCbCr, YCbCrA, YUV
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
That completes the installation if you only want to run ImageMagick under PHP outside your website.
The remaining steps are only necessary if you want to run PHP and ImageMagick under Apache inside your website.
# Check if PHP module loaded in Apache config file - /etc/apache2/httpd.conf
grep "^LoadModule.*php5_module.*libphp.*" /etc/apache2/httpd.conf
Check it matches, or if not present add a line like this
LoadModule php5_module /usr/local/Cellar/php56/5.6.6/libexec/apache2/libphp5.so
# Restart Apache
sudo apachectl restart

Related

pdfcairo 'unknown or ambiguous terminal type' in gnuplot

After upgrading gnuplot from 4.6 to 5.0.1, I encounter the following error:
set terminal pdfcairo size 3.0in,2.25in font ',8'
^
"plot.plt", line 114: unknown or ambiguous terminal type; type just 'set terminal' for a list
How can I fix it?
PS: pdfcairo works fine in the previous version (4.6).
I install the gnuplot by the following command:
#build it:
./configure --with-cairo
make
#install it:
sudo make install
As described in GNUPLOT Version 5.0.1 Release Notes, the pdfcairo is included by default.
Cairo/pango/wxWidgets This set of terminals includes
pngcairo, pdfcairo, epscairo, and cairolatex for output to a file
wxt for interactive display All of these will be built by default if the
configuration script finds the required libcairo, libpango, libcairo,
libwxgtk, and related support libraries To disable these terminals:
./configure --without-cairo ./configure --with-cairo --disable-wxt
I fix it with the kind reminder of #Christoph.
To tackle this issue, install the dependency libraries for cairo-based terminals by the follwoing command:
sudo apt-get install libcairo2-dev
sudo apt-get install libpango1.0-dev
And then compile gnuplot again:
#build it:
cd gnuplot-5.0.1 ; ./configure ; make
#install it:
sudo make install
Now, everything is fine. Enjoy it:-)
gnuplot> set term
Available terminal types:
cairolatex LaTeX picture environment using graphicx package and Cairo backend
canvas HTML Canvas object
cgm Computer Graphics Metafile
context ConTeXt with MetaFun (for PDF documents)
corel EPS format for CorelDRAW
dumb ascii art for anything that prints text
dxf dxf-file for AutoCad (default size 120x80)
eepic EEPIC -- extended LaTeX picture environment
emf Enhanced Metafile format
emtex LaTeX picture environment with emTeX specials
epscairo eps terminal based on cairo
epslatex LaTeX picture environment using graphicx package
fig FIG graphics language for XFIG graphics editor
hpgl HP7475 and relatives [number of pens] [eject]
latex LaTeX picture environment
mf Metafont plotting standard
mp MetaPost plotting standard
pcl5 HP Designjet 750C, HP Laserjet III/IV, etc. (many options)
pdfcairo pdf terminal based on cairo
pngcairo png terminal based on cairo
postscript PostScript graphics, including EPSF embedded files (*.eps)
Press return for more:

Can Tesseract be set to OCR only (no image modification) when producing a PDF?

Is there a way to force Tesseract to do OCR only and leave the original images intact? At the moment, I use the command:
tesseract -l eng file.tif file pdf
in order to produce file.pdf from a multipage tif file. My problem with this command is that Tesseract modifies the images. For example, thin lines that denote tables or some figures are removed. I'd like to stop this behavior and only OCR the document where the text is underlaid on the original image. In case it matters,
$ tesseract -v
tesseract 3.03
leptonica-1.71
libgif 4.1.6(?) : libjpeg 6b : libpng 1.6.16 : libtiff 4.0.3 : zlib 1.2.8 : libopenjp2 2.1.0
and
$ cat /usr/share/tessdata/configs/pdf
tessedit_create_pdf 1
tessedit_pageseg_mode 1
Using the current git repo of Tesseract, the resulting images look much better. Specifically:
$ ./tesseract -v
tesseract 3.04.00
leptonica-1.71
libgif 4.1.6(?) : libjpeg 6b : libpng 1.6.16 : libtiff 4.0.3 : zlib 1.2.8 : libopenjp2 2.1.0
and
git log -n 1
commit 941d87057e67d18aca2ed428543e7f24bbdba010
Author: Ray Smith <rays#google.com>
Date: Wed May 13 17:46:58 2015 -0700
Fixed training build
with
$ git branch
* master
Basically, all of the lines that used to be eliminated in 3.03 from tables and figures now remain. That being said, the image still is manipulated and the resolution is lower than the original image. Nevertheless, for my purposes, things look ok.

Rmagick unable to read font

I have a piece of code that draws text on top of an image in my Rails app and since short while ago, probably having to to with upgrading to OS X Yosemite, it's having an issue with reading fonts on my local machine (production server is working fine).
I can reduce it to this example:
require 'rvg/rvg'
font = '"/Users/xxxxxxxx/xxxx/app/assets/fonts/PTSans-Regular.ttf"'
rvg = Magick::RVG.new(100,100) do |canvas|
canvas.text(0, 0, 'my text').styles(font: font)
end
rvg.draw
I get this error
Magick::ImageMagickError: unable to read font `"/Users/xxxxxxxx/xxxx/app/assets/fonts/PTSans-Regular.ttf"' # error/annotate.c/RenderFreetype/1153: `(null)'
from /Users/xxxxxxxx/.rvm/gems/ruby-2.0.0-p353#xxxxxxxx/gems/rmagick-2.13.2/lib/rvg/misc.rb:322:in `get_type_metrics'
I tried reinstalling imagemagick and the rmagick gem, also with these flags:
brew install imagemagick --disable-openmp --build-from-source
Also, if I change
font = "/Users/xxxxxx/xxxxx/app/assets/fonts/PTSans-Regular.ttf"
thinking that the extra quotes could get in the way, then I get
Magick::ImageMagickError: non-conforming drawing primitive definition `Users/xxxxx/xxxx/app/assets/fonts/PTSans-Regular.ttf' # error/draw.c/DrawImage/3170
from /Users/xxxxxxx/.rvm/gems/ruby-2.0.0-p353#xxxx/gems/rmagick-2.13.2/lib/rvg/misc.rb:546:in `draw'
I have also tried to install the latest version of XQuartz from http://xquartz.macosforge.org/landing/
Strangely enough, this fixed it:
brew install gs
The error got me confused because it didn't say anything about ghostscript, however, it worked according to https://stackoverflow.com/a/13936374/322253

Spree demo missing product images

I followed the instructions on http://guides.spreecommerce.com/developer/getting_started_tutorial.html
Additionally, I followed instructions on http://codeofalice.com/code/installing-rmagick-on-windows-7/ to install imagemagick and rmagick gems. No errors reported.
When I run identify I get
Version: ImageMagick 6.7.7-8 2012-06-20 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
Usage: identify.exe [options ...] file [ [options ...] file ... ]
Image Settings:
-alpha option on, activate, off, deactivate, set, opaque, copy
transparent, extract, background, or shape
-antialias remove pixel-aliasing
The demo site runs, but the images are missing. Additionally, I can't upload images (no errors) - they just don't upload. I believe it is something related to ImageMagick, but am not sure.
Run bundle exec rake spree_sample:load It worked for me!

"ERROR: broken data stream when reading image file" (TrueType fonts libjpeg and PIL on OS X)

I'm running OS X 10.6.7, Python 2.6, and writing a small wxPython application that uses PIL to manipulate an image and add some text to it.
After quite a bit of configuration woes with attempting to get PIL running with libjpeg and PIL, I followed the instructions at this site.
Upon running python setup.py build_ext -i (from inside the Imaging-1.1.7 folder) I get:
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform darwin 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
--- LITTLECMS support available
--------------------------------------------------------------------
Additionally, running python selftest.py in the Imaging-1.1.7 install folder, I get:
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from ./PIL
--------------------------------------------------------------------
--- PIL CORE support ok
--- TKINTER support ok
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
--- LITTLECMS support ok
--------------------------------------------------------------------
Running selftest:
--- 57 tests passed.
However, when rendering my first PIL image in my own code, I still get:
File "/Library/Python/2.6/site-packages/PIL/Image.py", line 1290, in resize self.load()
File "/Library/Python/2.6/site-packages/PIL/ImageFile.py", line 215, in load raise_ioerror(e)
File "/Library/Python/2.6/site-packages/PIL/ImageFile.py", line 52, in raise_ioerror
raise IOError(message + " when reading image file")
IOError: broken data stream when reading image file
I'm kind of at a loss as to what to try next. Any ideas? The code that is causing this crash seems to be:
try:
self.img = self.img.resize((self.screenwidth, self.screenheight),
Image.ANTIALIAS)
except IOError, e:
print "Error resizing: " + str(e)
self.img = self.img.resize((self.screenwidth, self.screenheight))
raise
You should consider uninstalling PIL and following the instructions on this website -
http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/
In particular, it appears that you want to make sure that libjpeg is at version 6b, not 8c (see below)
I am able to reproduce this with Mac OS X 10.5 using macports
This is related to a another question:
How to solve IOError:broken data stream when reading image file?
The answer there indicates that the bug might have something to do with libjpeg
As far as I can tell, the error appears to be caused by a forward incompatibility with libjpeg v8c.
I cannot determine what is causing this exactly; all I can say is that on a variety of other systems I use that aren't exhibiting this behavior error (OS X 10.5 with fink, Redhat 5.2, Ubuntu 11.10 and 10.10), they all use libjpeg 6b. Only macports uses 8c, and macports is the only system where I am getting this error.
I was able to use PIL with the homebrew package manager.
I've got a similar error when reading .jpg file with an up-to-date Python environment and Sierra Mac OS. I've found a quick workaround which consists to convert all the .jpg files to .png files Hoping that can help someone else.

Resources