I have found that GraphicsMagick is unable to process my files named in Chinese. I did the same test on ImageMagick but IM worked as expected.
I thought this might be a bug so I filed a bug report here: https://sourceforge.net/p/graphicsmagick/bugs/384/
Anyway, this is how to reproduce my situation:
Platform: Win10
Version: GraphicsMagick 1.3.20
Code: gm -identify 獅藝學會.jpg
This is the returned text from Command Prompt:
>gm -identify 獅藝學會.jpg
gm identify: Unable to open file (????.jpg) [Invalid argument].
gm identify: Request did not return an image.
Using IM worked:
identify 獅藝學會.jpg
ç?.è-?å-,æoƒ.jpg JPEG 3264x2448 3264x2448+0+0 8-bit sRGB 2.691MB 0.016u 0:00.004
Although the text returned is scrambled, but converting the file to a .png still maintained the same filename apart from the different extensions of course.
What happened
I found this problem by using the gm node.js library batch processing my images, the source of the call is made from a UTF-8 webpage, so I assume the filename is passed as Unicode encoding.
I found no documentation related to this problem, although the documentation states that there was a -encoding option, it cannot be sent as parameter on Windows as it does not recognize it and I cannot find relevant solutions on Google.
Please help, is there any easy way around this problem, while keeping the exact filename?
In case someone uses the C api.
(You can only give (char *)-type filenames. And UTF-8 encoding does not work, if using GraphicsMagick on Windows.)
You could do the following:
Open the file for input (or output) yourself (use fopen(), _wfopen() etc).
Then set the filehandle within the ImageInfo structure for reading and Image structure for writing respectively (instead of setting the filename).
To have GraphicsMagick generate the right output file format, set magick within the Image structure.
f.e.:
//Reading
imageInfo->file=_wfopen(input_filename,L"rb"); //ImageInfo *imageInfo;
ReadImage(imageInfo,exception);
//Writing
image->file=_wfopen(output_filename,L"wb"); //Image *image;
strcpy(image->magick,"PNG");
WriteImage(imageInfo,image);
GraphicsMagick automatically closes the file after writing/reading.
I have the same problem using GM in C++. UTF-8 filenames are not supported under Windows (not even in the API!).
My workaround is to get the short path name (8.3), you can do that both using command line and Win32. However this doesn't work 100% - and if you want to save a file you have to create an empty one first to be able to get the short name.
Related
I am trying to read all the information related to the camera for a generic RAW image file though NodeJS (Camera properties example). Although I've tried several ways, none of them leads to a solution. There are a few modules which works fine for JPEG/TIFF files, but none are generic.
Also trying the shell command
wmic datafile where name="C:\\path\\to\\file.ext"
does not help since the list of properties retrieved is not complete.
When using the LAME interface through a node application (I am writing a JavaScript program running on node, with LAME installed), I am now getting this error on a semi-regular basis:
"MPEG-2.5 is supported by Layer3 only"
I am using LAME to convert mp3's to WAV files, so I need this to work for all mp3s.
What should I be doing to the mp3s (or to my call to LAME) to make these mp3 files convertible via LAME?
This error is often the result of someone who has taken an mp4 file and changed the name to mp3 extension. This shows up especially for windows, since it uses extensions to indicate file type rather than purely inspecting the file content.
In this case, using LAME to try to convert a file like (helloworld.mp3 - which was originally helloworld.mp4):
LAME --decode helloworld.mp3 helloworld.wav
will give you the following message
"LAME error: MPEG-2.5 is supported by Layer3 only"
I am writing a nodejs app which works with fonts. One action it performs is that it downloads a .ttf font from the web, converts it to a base64 string, deletes the .ttf and uses that string in other stuff. I need the .ttf file stored somewhere, so I convert it. This process takes like 1-2 seconds. I know heroku has an ephemeral file system but I need to store stuff for such a short time. Is there any way I can store my files? Using fs.writeFile currently returns this error:
Error: EROFS: read-only file system, open '/app\test.txt']
I had idea how about you make an action, That would get font, convert it and store it on a global variable before used by another task.
When you want to use it again, make sure you check that global variable already filled or not with that font buffer.
Reference
Singleton
I didn't know that you could store stuff in /tmp directory. It is working for the moment but according to the dyno/ephemeral system, it gets cleaned frequently so I don't know if it may cause other problems in the long run.
I'm using SDL2 and the SDL mixer library to attempt to play a WAV file. After calling the Mix_LoadWAV_RW function, I get the following error string: "Unsupported block alignment" In case it matters, I'll note that I got the *SDL_RWops by calling SDL_RWFromMem on a WAV file I have embedded into my source code as an array of bytes. That is, the first several bytes are the WAV header containing the text "RIFF: and "WAVE".
I'm guessing this means I need to re-encode my WAV file to a sub-format with a supported block alignment, but that is mostly a guess. Given I go with that guess, it seems like I would need to know what block alignments are supported. I'm unable to find any relevant info in the docs about which alignments are supported.
I've also tried searching this github mirror of the source code for SDL mixer for "Unsupported block alignment" but I didn't get any results. Does that mean that the error is coming from some dependency of SDL Mixer or something?
Does anyone know more about this error, where I can find more information on this error, or even a reasonable guess as to how I should change my WAV file to work here?
For the record, I ended up just re-encoding the WAV file with default settings in Audacity, and it seems to have worked after that.
I am curling a website and writing it to .json file; this file is input to my java code which parses it using json library and the necessary data is written back in a CSV file which i later use to store it in a database.
As you know data coming from a website can be in different formats so i make sure that i read and write in UTF-8 format, still i get wrong output.
For example, Østerriksk becomes �sterriksk.
I am doing all this in Linux. I think there is some encoding problem because this same code runs fine in Windows but not in Unix/Linux.
I am quite sure my java code is proper but i am not able to find out what I'm doing wrong.
You're reading the data as ISO 8859-1 but the file is actually UTF-8. I think there's an argument (or setting) to the file reader that should solve that.
Also: curl isn't going to care about the encodings. It's really something in your Java code that's wrong.
What kind of IDE are you using, for example this can happen if you are using Eclipse IDE, and not set your default encoding to utf-8 in properties.