[SOLVED] Blob: Linux vs. Windows(MinGW)

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

[SOLVED] Blob: Linux vs. Windows(MinGW)

Post by olear » 2016-04-03T10:33:50-07:00

Hi,

I'm reading a SVG from a stringstream, and everything works as I want in Linux, but when I started testing in Windows(MinGW) I noticed some strange issues.

I do this (the SVG is contained in the 'stream'):

Code: Select all

Magick::Blob blob(static_cast<const void *>(stream.str().c_str()),stream.str().size());
image.read(blob);
image.write(....);
This works fine on Linux, but on Windows(MinGW) I get:
UnableToOpenBlob 'path_to_temp/magick-XXXXXX': No such file or directory @ error/blob.c/OpenBlob/2702
If I replace '.read' with '.ping' I'm able to query the image size, and get no error.

Btw, isn't Blob supposed to be in memory not saved on the filesystem?
Last edited by olear on 2016-04-09T10:49:22-07:00, edited 1 time in total.

User avatar
dlemstra
Posts: 1588
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Blob: Linux vs. Windows(MinGW)

Post by dlemstra » 2016-04-03T11:02:43-07:00

Blob is from memory but it is possible that the SVG delegate that you are using requires a file when you read it. Inkscape is one of that delegates that requires that. It is odd that it works when you do ping because that should do the same. What is your SVG delegate on Windows?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Blob: Linux vs. Windows(MinGW)

Post by olear » 2016-04-03T11:05:09-07:00

I use RSVG on both Linux and Windows.

ImageMagick version 6.9.3-5 Q32HDRI with cairo, fontconfig, freetype, lcms, pangocairo, png, rsvg, xml, zlib.

User avatar
dlemstra
Posts: 1588
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Blob: Linux vs. Windows(MinGW)

Post by dlemstra » 2016-04-03T11:13:52-07:00

And are you using an x86 or x64 build? Maybe you are hitting a memory limit in librsvg when you read all the pixels? You need quite a lot of memory with a Q32-HDRI build.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Blob: Linux vs. Windows(MinGW)

Post by olear » 2016-04-03T11:30:34-07:00

I'm on x64, and memory should not be a problem. I'm using IMQ32+RSVG on a daily basis, but from a file. Also the problem should manifest itself on Linux too if memory was the issue (I build IM and depends identical on both platforms)?

I can of course try to rebuild IM with lower Quantum, but I doubt that will change anything.

Also the image is smaller then 800x600.

User avatar
dlemstra
Posts: 1588
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Blob: Linux vs. Windows(MinGW)

Post by dlemstra » 2016-04-03T11:35:26-07:00

Can you share the image so I can run it through a debugger? Send me a PM if you don't want to share it publicly.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Blob: Linux vs. Windows(MinGW)

Post by olear » 2016-04-03T14:52:49-07:00

Happens with any SVG, currently testing with:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg:svg version="1.1" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="612.0000" height="792.0000" >
<svg:g id="Layer1000" >
<svg:path d="
M248.5722,313.5199
C286.0311,351.3391 251.5994,444.2915 351.4266,435.6785
C135.3714,503.8092 162.7146,226.8327 248.5722,313.5199
Z"
style="fill-rule: evenodd; fill: #00ff00; "/>
<svg:path d="
M355.4542,316.5640
C357.2108,354.8566 293.9365,387.9004 351.4352,431.4938
C203.0981,363.5886 351.4299,228.7934 355.4542,316.5640
Z"
style="fill-rule: evenodd; fill: #0000ff; "/>
<svg:path d="
M419.1075,365.6919
C399.8818,388.5695 346.1535,374.0783 356.0787,429.4467
C306.9301,312.1468 463.1757,313.2551 419.1075,365.6919
Z"
style="fill-rule: evenodd; fill: #ff6600; "/>
<svg:path d="
M365.1285,431.9341
C334.9629,472.8561 230.5034,460.9752 204.9837,433.2682
C220.1241,489.2392 342.5426,562.8036 399.0555,427.3596
C402.1712,419.8979 406.3505,411.6497 411.3621,413.3209
L424.0858,417.1050
L417.1878,404.8308
C395.0314,365.4028 376.7381,416.1852 365.1285,431.9341
Z"
style="fill-rule: evenodd; fill: #0000ff; "/>
</svg:g>
<svg:path d="
M90.5681,206.8804
L90.5681,585.1196
L521.4319,585.1196
L521.4319,206.8804
L90.5681,206.8804
Z"
style="fill: none; "/>
</svg:svg>

Loading the files through normal read is ok, but using the Blob don't work (but I have other apps/plugins that uses blob for PNG and they have no issues on Windows). Strange ...

User avatar
dlemstra
Posts: 1588
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Blob: Linux vs. Windows(MinGW)

Post by dlemstra » 2016-04-04T13:09:42-07:00

I cannot reproduce your issue. Are you sure you are not using inkspace in your delegates.xml file?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Blob: Linux vs. Windows(MinGW)

Post by olear » 2016-04-04T13:29:21-07:00

I'm on a clean install of Windows 7, no applications installed (except for compiler and depends).

User avatar
dlemstra
Posts: 1588
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Blob: Linux vs. Windows(MinGW)

Post by dlemstra » 2016-04-04T13:37:21-07:00

Can you post the a small .cpp file that I could use to reproduce this?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Blob: Linux vs. Windows(MinGW)

Post by olear » 2016-04-05T05:07:01-07:00

Sorry for the late reply, will try to make a small example after work today.

olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Blob: Linux vs. Windows(MinGW)

Post by olear » 2016-04-05T12:19:56-07:00

This should do:

Code: Select all

    Magick::Image image;
    std::ostringstream svg;
    svg << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><svg:svg version=\"1.1\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"612.0000\" height=\"792.0000\" ><svg:g id=\"Layer1000\" ><svg:path d=\"M248.5722,313.5199 C286.0311,351.3391 251.5994,444.2915 351.4266,435.6785 C135.3714,503.8092 162.7146,226.8327 248.5722,313.5199 Z\" style=\"fill-rule: evenodd; fill: #00ff00; \"/><svg:path d=\"M355.4542,316.5640 C357.2108,354.8566 293.9365,387.9004 351.4352,431.4938 C203.0981,363.5886 351.4299,228.7934 355.4542,316.5640 Z\" style=\"fill-rule: evenodd; fill: #0000ff; \"/><svg:path d=\"M419.1075,365.6919 C399.8818,388.5695 346.1535,374.0783 356.0787,429.4467 C306.9301,312.1468 463.1757,313.2551 419.1075,365.6919 Z\" style=\"fill-rule: evenodd; fill: #ff6600; \"/><svg:path d=\"M365.1285,431.9341 C334.9629,472.8561 230.5034,460.9752 204.9837,433.2682 C220.1241,489.2392 342.5426,562.8036 399.0555,427.3596 C402.1712,419.8979 406.3505,411.6497 411.3621,413.3209 L424.0858,417.1050 L417.1878,404.8308 C395.0314,365.4028 376.7381,416.1852 365.1285,431.9341 Z\" style=\"fill-rule: evenodd; fill: #0000ff; \"/></svg:g><svg:path d=\"M90.5681,206.8804 L90.5681,585.1196 L521.4319,585.1196 L521.4319,206.8804 L90.5681,206.8804 Z\" style=\"fill: none; \"/></svg:svg>";
    Magick::Blob blob(static_cast<const void *>(svg.str().c_str()),svg.str().size());
    try {
        image.read(blob);
    }
    catch(Magick::Error &error) {
        std::cout << error.what() << std::endl;
    }
    std::cout << image.columns() << "x" << image.rows() << std::endl;
Works on Linux, but not Windows.

I used qtcreator (I'm lazy), complete project if you want:

Code: Select all

QT += core
QT -= gui

TARGET = magicksvg
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

CONFIG += link_pkgconfig
PKGCONFIG += Magick++

QMAKE_CXXFLAGS += `pkg-config Magick++ --cflags`
LIBS += `pkg-config Magick++ --libs --static`
win32: LIBS += -lws2_32

Code: Select all

#include <QCoreApplication>
#include <iostream>
#include <sstream>
#include <Magick++.h>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    Magick::Image image;
    std::ostringstream svg;
    svg << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><svg:svg version=\"1.1\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"612.0000\" height=\"792.0000\" ><svg:g id=\"Layer1000\" ><svg:path d=\"M248.5722,313.5199 C286.0311,351.3391 251.5994,444.2915 351.4266,435.6785 C135.3714,503.8092 162.7146,226.8327 248.5722,313.5199 Z\" style=\"fill-rule: evenodd; fill: #00ff00; \"/><svg:path d=\"M355.4542,316.5640 C357.2108,354.8566 293.9365,387.9004 351.4352,431.4938 C203.0981,363.5886 351.4299,228.7934 355.4542,316.5640 Z\" style=\"fill-rule: evenodd; fill: #0000ff; \"/><svg:path d=\"M419.1075,365.6919 C399.8818,388.5695 346.1535,374.0783 356.0787,429.4467 C306.9301,312.1468 463.1757,313.2551 419.1075,365.6919 Z\" style=\"fill-rule: evenodd; fill: #ff6600; \"/><svg:path d=\"M365.1285,431.9341 C334.9629,472.8561 230.5034,460.9752 204.9837,433.2682 C220.1241,489.2392 342.5426,562.8036 399.0555,427.3596 C402.1712,419.8979 406.3505,411.6497 411.3621,413.3209 L424.0858,417.1050 L417.1878,404.8308 C395.0314,365.4028 376.7381,416.1852 365.1285,431.9341 Z\" style=\"fill-rule: evenodd; fill: #0000ff; \"/></svg:g><svg:path d=\"M90.5681,206.8804 L90.5681,585.1196 L521.4319,585.1196 L521.4319,206.8804 L90.5681,206.8804 Z\" style=\"fill: none; \"/></svg:svg>";
    Magick::Blob blob(static_cast<const void *>(svg.str().c_str()),svg.str().size());
    try {
        image.read(blob);
    }
    catch(Magick::Error &error) {
        std::cout << error.what() << std::endl;
    }
    std::cout << image.columns() << "x" << image.rows() << std::endl;

    return 1;
}

snibgo
Posts: 12429
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Blob: Linux vs. Windows(MinGW)

Post by snibgo » 2016-04-05T12:43:02-07:00

After removing the two lines with "QCoreApplication", the program compiles and runs under IM v6.9.3-7 Q32 HDRI, Cygwin, Windows 8.1, writing the output:

Code: Select all

612x792
snibgo's IM pages: im.snibgo.com

olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Blob: Linux vs. Windows(MinGW)

Post by olear » 2016-04-05T13:05:58-07:00

That's odd, here with Win7 and MinGW I get unable to open blob (in example and in main app).

snibgo
Posts: 12429
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Blob: Linux vs. Windows(MinGW)

Post by snibgo » 2016-04-05T13:36:13-07:00

My only experience with MinGW is failing to even build IM with it some years ago. No problems with Cygwin, under Windows 7, 8 or 8.1.
snibgo's IM pages: im.snibgo.com

Post Reply