imread() stopped working on Octave - image

I've tried googling it and it seems nobody else has had this kind of error.
I'm using Octave 3.6.1 on Ubuntu 12.04. I've been using the imread() funcion to read images for quite some time, but just yesterday it started throwing this error:
octave:5> I = imread('example.jpg');
error: imread: invalid image file: Magick++ exception: Magick: Unable to open file (tures/example.jpg) reported by coders/jpeg.c:955 (ReadJPEGImage)
error: called from:
error: /usr/share/octave/3.6.1/m/image/imread.m at line 74, column 7
If I try to read a PNG, I get a similar error:
octave:5> I = imread('example.png');
error: imread: invalid image file: Magick++ exception: Magick: Unable to open file (tures/example.png) reported by coders/png.c:2790 (ReadPNGImage)
error: called from:
error: /usr/share/octave/3.6.1/m/image/imread.m at line 74, column 7
Does anybody know what's happening? How to fix this?
Thanks a lot!

I had the same problem with 3.6.4 on Windows 8.1, the simple workaround for me was this:
IMAGE_PATH = ('C:\Users\...');
where the image is stored
Image = file_in_path(IMAGE_PATH, 'image.jpg');
Of course it would be better to fix the actual function, but for now it's good enough.
Hope this helps.

Octave uses GraphicsMagick (or ImageMagick) to handle the reading and writing of images. GraphicsMagick does not handle directly the reading and writing of images, it's a wrapper for the many format libraries under a single API.
When you build GraphicsMagick, it checks your system for available libraries and disables/activates formats as those are presents. You probably built GraphicsMagick yourself without the development libraries libpng and libjpeg. In Ubuntu, I believe those are in the packages libpng12-dev and libjpeg8-dev. Either use the GraphicsMagick libraries that come with your system or if you need to build it yourself, see the instructions in the Octave wiki.
To confirm this is indeed your problem, run gm -version and check if those formats are activated. For example, the output in my system shows:
Feature Support:
Thread Safe yes
Large Files (> 32 bit) yes
Large Memory (> 32 bit) no
BZIP yes
DPS no
FlashPix no
FreeType yes
Ghostscript (Library) no
JBIG yes
JPEG-2000 yes
JPEG yes
Little CMS yes
Loadable Modules no
OpenMP yes (201107)
PNG yes
TIFF yes
TRIO no
UMEM no
WMF yes
X11 yes
XML yes
ZLIB yes

Related

libgstvulkan-1.0.0.dylib missing from GStreamer plugins bad on OS X/Homebrew

On OS X 12.1, with I'm building an app that is complaining about:
dyld[12690]: Library not loaded: #rpath/lib/libgstvulkan-1.0.0.dylib
I've installed the following with Homebrew:
GStreamer 1.18.5 installed form homebrew
gst-plugins-ugly
gst-plugins-base
gst-plugins-bad
gst-plugins-good
I've been able to find all the required .dylib files so far, except for libgstvulkan-1.0.0.dylib, which should be included with gst-plugins-bad but doesn't appear to be in the Homebrew install.
Questions:
what am I missing? why don't I have libgstvulkan-1.0.0.dylib on my system and where do I get it?
I'd like to know how I can avoid Homebrew and just install the packages directly but I don't see how to get the bad plugins from that side. Do I need to build from source?
My understanding is there is no vulcan dependency in the homebrew formula, thus when building the artifact, there is no libgstvulkan-1.0.0.dylib artifact.
I tried to include molten-vk for the build and turned on vulkan flag, but it has some issue of finding the vulkan_core.h (which is already in /opt/homebrew/Cellar/molten-vk/1.1.8/libexec/include/vulkan/vulkan_core.h).
Local build error:
==> meson --prefix=/opt/homebrew/Cellar/gst-plugins-bad/1.18.5_1 --libdir=/opt/homebrew/Cellar/gst-plugins-bad/1.18.5_1/lib --buildtype=release --wrap-mode=nofallback -Dintrosp
Last 15 lines from /Users/rui/Library/Logs/Homebrew/gst-plugins-bad/01.meson:
Program g-ir-compiler found: YES (/opt/homebrew/Cellar/gobject-introspection/1.70.0_3/bin/g-ir-compiler)
Program glib-mkenums found: YES (/opt/homebrew/opt/glib/bin/glib-mkenums)
Program glib-mkenums found: YES (/opt/homebrew/opt/glib/bin/glib-mkenums)
Program glib-mkenums found: YES (/opt/homebrew/opt/glib/bin/glib-mkenums)
Program glib-mkenums found: YES (/opt/homebrew/opt/glib/bin/glib-mkenums)
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency opencv found: NO (tried pkgconfig, framework and cmake)
Run-time dependency opencv4 found: NO (tried pkgconfig, framework and cmake)
Library MoltenVK found: YES
Has header "vulkan/vulkan_core.h" : NO
../gst-libs/gst/vulkan/meson.build:146:2: ERROR: Problem encountered: vulkan plugin enabled, but vulkan.h not found
A full log can be found at /private/tmp/gst-plugins-bad-20220227-60197-31i3hx/gst-plugins-bad-1.18.5/build/meson-logs/meson-log.txt
Feel free to kick off a PR and we can get this forward.

Installing Cairo on Mac - Could not find libpng in the pkg-config search path

checking whether cairo's PNG functions feature could be enabled... no
I have been following the setup for configuring node canvas. Cairo is needed but i am having issues trying to set it up. https://github.com/Automattic/node-canvas/wiki/Installation---OSX
If libpng fails and you get the error "error: recommended PNG functions feature could not be enabled", try installing this binary and re-running the configure step.
I followed above by installing the binaries on Mac OS 9 and run the configuration command and still no luck. I am running the install shell script in node-canvas repository:
https://github.com/Automattic/node-canvas/blob/master/install
In my /usr/local/lib I currently have:
dtrace libjpeg.8.dylib libpng.a libpng14.a
libfreetype.6.dylib libjpeg.a libpng.dylib libpng14.dylib
libfreetype.a libjpeg.dylib libpng.la libpng14.la
libfreetype.dylib libjpeg.la libpng12.0.dylib libpng15.15.dylib
libfreetype.la libpixman-1.0.dylib libpng12.0.dylib.dSYM libpng15.15.dylib.dSYM
libgif.4.1.6.dylib libpixman-1.a libpng12.a libpng15.a
libgif.4.dylib libpixman-1.dylib libpng12.dylib libpng15.dylib
libgif.a libpixman-1.la libpng12.la libpng15.la
libgif.dylib libpng.3.dylib libpng14.14.dylib node_modules
libgif.la libpng.3.dylib.dSYM libpng14.14.dylib.dSYM pkgconfig
Libpng-1.6.10 has been replaced by libpng-1.6.12.
In your install script, change
LIBPNG="http://downloads.sourceforge.net/project/libpng/libpng16/1.6.10/libpng-1.6.10.tar.gz"
to
LIBPNG="http://downloads.sourceforge.net/project/libpng/libpng16/1.6.12/libpng-1.6.12.tar.gz"
I have a set of detailed instructions for building cairo here:
https://github.com/soegaard/racket-osx-libs
There resulting libraries are here:
https://github.com/soegaard/racket-osx-libs/tree/master/lib

To view dvi files under osx 10.9. X11 and Ghostscript issue

I just have upgraded to os x 10.9 (clean install), but am finding issues with ghostscipt (or with X11-quartz). I need to view a dvi file (from latex) with this line command in Terminal
$ xdvi doc.dvi
The text appears fine, but the figures (.eps, .ps) do not show up. It left blank rectangles instaed. I get this error message
Warning: Unable to load any usable fontset
gs: Unknown device: x11
gs: Unrecoverable error: undefined in .uninstallpagedevice
gs: Operand stack:
gs: defaultdevice
xdvi-xaw: Warning: Read_from_gs returned 0 bytes
P.S. I installed XQuartz 2.7.5 (xorg-server 1.14.4), and GPL Ghostscript 9.07.
Any guidance please?
The first answer is correct, as re-installing MacTex should relink gs to gs-X11.
You can also just relink it yourself. For instance:
ls -l /usr/local/bin/gs
/usr/local/bin/gs -> /usr/local/bin/gs-noX11
sudo ln -sf /usr/local/bin/gs-X11 /usr/local/bin/gs
Now xdvi displays the images. Tested on Mavericks 10.9.4.
I reinstalled latex with MacTex again and now seems working fine.
Perhaps one needs to first install ghostscript then latex (?)
But note that I did some manipulations prior to this... In fact I reinstalled Ghostscript with mac ports. But even at that time it did not work, until I reinstalled Latex as highlighted above.

"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.

Octave + GNUPlot + Aquaterm + Mac OS 10.6

I'm attempting to do all of my MatLab based homework assignments in Octave - the opensource representation of MatLab.
However, I'm having problems getting graphs to plot and I think it's a simple linking problem. I am running:
-Mac OS X Snow Leopard (10.6)
-Octave 3.2.2
-Aquaterm 1.0.1
-GNUPlot 4.0
Here is an example of the errors that I am getting from my shell:
Mr-Buffalo:~ buffingtonr$ gnuplot
dyld: Library not loaded: /usr/local/lib/libaquaterm.1.0.0.dylib
Referenced from: /usr/local/bin/gnuplot
Reason: image not found
Trace/BPT trap
octave-3.2.2:1> f = inline('x^2')
f(x) = x^2
octave-3.2.2:5> ezplot(f)
dyld: Library not loaded: /usr/local/lib/libaquaterm.1.0.0.dylib
Referenced from: /usr/local/bin/gnuplot
Reason: image not found
dyld: Library not loaded: /usr/local/lib/libaquaterm.1.0.0.dylib
Referenced from: /usr/local/bin/gnuplot
Reason: image not found
error: you must have gnuplot installed to display graphics; if you have gnuplot installed in a non-standard location, see the 'gnuplot_binary' function
octave-3.2.2:6>
I don't have the unix foundation necessary to trouble shoot this. Any suggestions/fixes?
the problem could be related to this
http://macresearch.org/gnuplot-aquaterm-snow-leopard-1061
in the answer: Fri, 2009-09-18 01:59 — TeGa
You have aquaterm 1.0.1 installed, and gnuplot is referencing 1.0.0, which you apparently do not have installed on your system.
I'm not terribly familiar with installing a library on a Mac, but you might be able to just grab the 1.0.0 .dmg file from the Aquaterm files page on Sourceforge.
Alternatively, the newest version of octave or gnuplot might reference the newer library, so you might be able to just upgrade one of those instead.
It's a real hack, but I saw a couple places (including this mailing list) suggesting you just link 1.0.0 to your 1.0.1 library. This isn't usually acceptable, because there's no guarantee the libraries are cross-compatible. It would at least be a quick fix so you can get your homework done in time!
New Progress
When I investigated '/usr/local/lib/', I found that there was a symbolic-link in the directory:
aquaterm-1.0.0 -> /Library/Frameworks/AquaTerm.framework/Versions/A/AquaTerm
So I created a similar sym-link to make the file gnuplot is looking for (...1.0.1) point to the default AquaTerm location:
aquaterm-1.0.1 -> /Library/Frameworks/AquaTerm.framework/Versions/A/AquaTerm
This fixes the gnuplot launching issue. I verified that gnuplot successfully plots on its own by plotting a function:
Terminal type set to 'x11'
gnuplot> plot sin(x)
Now I get new errors in Octave:
octave-3.2.2:7> ezplot(f=inline('sin(x)'))
gnuplot> set terminal aqua enhanced title "Figure 1"
^
line 0: You can't change the terminal in multiplot mode
gnuplot> if (exists("GPVAL_TERM")) print GPVAL_TERM; else print NaN
^
line 0: invalid expression
error: Invalid call to strcat. Correct usage is:
-- Function File: strcat (S1, S2, ...)
However, I have verified that gnuplot 4.0 is installed and does, in fact, plot graphs. So now it seems the error is in the communication between Octave and GNUPlot. I will try updating to a newer version of gnuplot if possible and report back.
-Buffalo
This worked for me:
Step 1:
Replace /Library/Frameworks/AquaTerm.framework with /opt/local/Library/Frameworks/AquaTerm.framework. This will ensure that the correct 64 bit AquaTerm libraries get referenced by the gnuplot compilation
Step 2:
Replace /Applications/AquaTerm.app with /Applications/MacPorts/AquaTerm.app. This will ensure that the correct 64-bit AquaTerm binary is in the correct location
source:
http://slashusr.wordpress.com/2010/01/17/gnuplot-with-aquaterm-on-osx-snow-leopard/

Resources