Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path options when calling commands #42

Closed
DevinKott-KA opened this issue Jun 21, 2019 · 9 comments
Closed

path options when calling commands #42

DevinKott-KA opened this issue Jun 21, 2019 · 9 comments

Comments

@DevinKott-KA
Copy link

I'm in a file a couple directories down from the top, ie ./src/app/xxx/yyy/zzz/file.js
I have a profile I'm trying to apply to an image that's located in ./src/filters/tester.icm.

How should I go about locating tester.icm? I tried using the path ./src/filters/tester.icm, it didn't work. I tried moving tester.icm (using gulp) into dist and just trying ./tester.icm and that didn't work either.

I tried -debug All, but that just told me it couldn't find the file, it didn't tell me the full path it was looking for.

@cancerberoSgx
Copy link
Collaborator

Provide the file as input file together with input images and in the command reference it using the same name / path. The library will create files passed in inputFiles and then execute the commands. Didn't test it but this should work:

import { buildInputFile, execute, loadImageElement } from 'wasm-imagemagick'

const image1 = await buildInputFile('http://some-cdn.com/foo/fn.png', 'image1.png')
const testerIcm = {name: 'tester.icm', content: itsContentAsTypedArray}
const { outputFiles, exitCode} = await execute({
  inputFiles: [image1, testerIcm],
  commands: [
    'convert image1.png -rotate 70 -something tester.icm image2.gif',
...
  ],
})

See https://github.com/KnicKnic/WASM-ImageMagick/blob/master/apidocs/interfaces/magickinputfile.md

https://github.com/KnicKnic/WASM-ImageMagick/tree/master/apidocs#buildinputfile

@DevinKott-KA
Copy link
Author

Perfect! I got the file upload working, however ICM/ICC files appear to not be currently supported. It kept throwing an unknown file type. Could it be that the delegates precompiled do not include one that supports ICM/ICC file types?

@cancerberoSgx
Copy link
Collaborator

cancerberoSgx commented Jun 24, 2019

So you did tried something like this and it didn't work?:

convert rgb_image.jpg -profile USCoat.icm cmyk_image.jpg

Did you checked http://www.imagemagick.org/Usage/formats/#profiles ?

I never done that but this seems to be a common problem for users... Could you share the command you are trying to execute ? not the files, just the command.

Also does the command work on the desktop ?

Maybe could be useful you to share how are building the file - as a blob? request ? embedded in a .js file as base64 string ?

S since other users have the same problem would be awesome to solve the issue and make some notes in the readme.

Thanks

@DevinKott-KA
Copy link
Author

DevinKott-KA commented Jun 25, 2019

So you did tried something like this and it didn't work?:

convert rgb_image.jpg -profile USCoat.icm cmyk_image.jpg

Did you checked http://www.imagemagick.org/Usage/formats/#profiles ?

I never done that but this seems to be a common problem for users... Could you share the command you are trying to execute ? not the files, just the command.

Also does the command work on the desktop ?

Maybe could be useful you to share how are building the file - as a blob? request ? embedded in a .js file as base64 string ?

S since other users have the same problem would be awesome to solve the issue and make some notes in the readme.

Thanks

Sure. I first import my ICM file through the file-loader webpack:

import tester from "../../../filters/tester.icm";

The output of 'tester' is:
29a2bd60465f1bb147e54a2717ce73c5.icm

Then on a button click, I run the imagemagick command. I first convert the profile into a byte array:
const fetchedIcmProfile = await fetch(tester);
const icmContentArrayBuf = await fetchedIcmProfile.arrayBuffer();
const icmContent = new Uint8Array(icmContentArrayBuf);
const testerIcm = { name: "tester.icm", icmContent };

And then I ran the command:

const command = [
     "convert",
    "srcFile.jpeg",
    "-profile",
    "icm:tester.icm",
    "out.jpeg"
];

I get this output:
2019-0625-083547 Message: Error: Unsupported data type - URL: http://localhost:8080/magick.js - Line: 90 - Column: 0 - Error object: null
Error: Unsupported data type

Before, I was just using "tester.icm", but it was suggested to use "icm:tester.icm". Neither worked for me.

@KnicKnic
Copy link
Owner

@DevinKott-KA

Can you clarify, this is no longer a path options bug, but rather a profile issue. Correct?

@DevinKott-KA
Copy link
Author

@KnicKnic Correct. I have successfully loaded the ICM file. The issue now is that ICM profiles are not supported with the current WebASM-ImageMagick build. That is the error output I am getting in the console.

@cancerberoSgx
Copy link
Collaborator

I don't have real experience with profiles but did that command works on the server ? According to the profile (link above) is not a trivial topic... first make sure it works on the real thing...

But I suspect we are missing to include some IM configuration xml files in the build that supports this since some commands to get configuration are not working like (["convert","-list","configure"]). Hopefully with the new build knik is working on this get's solved. @KnicKnic could you please leave this issue open to track the problem since I and other users are having similar problems ? thanks!

@DevinKott-KA
Copy link
Author

DevinKott-KA commented Jun 26, 2019

@cancerberoSgx I can successfully run the command (["convert", "srcFile.jpeg", "-profile", "tester.icm", "out.jpeg"]) on my instance of ImageMagick in windows (from the command prompt) and have it work.
Running (["magick", "-list", "configure"]) on my desktop also produces a long list of delegates, including "lcms". However, running (["convert", "-list", "configure"]) in the WebASM-ImageMagick port, I get very little delegates compared to the windows version, and the javascript/webasm version does not have the "lcms" delegate.

EDIT: By server, do you mean the site I am using WASM-ImageMagick on? I specified a couple posts up the input/output of what I'm trying to do already.

@KnicKnic
Copy link
Owner

KnicKnic commented Jun 26, 2019

@DevinKott-KA
Correct lcms needs to be added, I cannot add it to the build system if I don't know how to test it. please see #45 (comment)

I am closing this due to it being a dupe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants