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

renderFile format options #956

Open
jonshutt opened this issue Aug 24, 2020 · 4 comments
Open

renderFile format options #956

jonshutt opened this issue Aug 24, 2020 · 4 comments
Assignees
Labels

Comments

@jonshutt
Copy link

Hi,
I'm rendering a bunch of files, but struggling with the format option

map.renderFile(filePath, { format: format }, (err) => { ... }

Eg, format = webp:quality=90 outputs the same file sizes as webp:quality=30, and jpg outputs the same as jpg30 as jpg90.

I'm referencing https://github.com/mapnik/mapnik/wiki/Image-IO to write the formatting options.

Is there something I'm missing?

@artemp artemp self-assigned this Aug 24, 2020
@artemp
Copy link
Member

artemp commented Aug 24, 2020

@jonshutt - your syntax looks fine to me ^ I'm not familiar with all webp options. This can be mapnik core issue or node-mapnik - I'll find time to debug this issue. Could you post details about your setup - mapnik/node-mapnik versions etc, thanks

@artemp artemp added the bug label Aug 26, 2020
@artemp
Copy link
Member

artemp commented Aug 26, 2020

@jonshutt - ok, I see what's wrong: renderFile (async) expects image_format option while renderFileSync expects format. Looks like a bug/typo to me. As a quick workaround you should be able to :

map.renderFile(filePath, { image_format: "webp:quality=30" }, (err) => { ... }

@jonshuttsnap40
Copy link

jonshuttsnap40 commented Aug 26, 2020

@artemp I just gave that go - but it still didn't seem to make any difference. I did however do a bit more reading, and changed from renderFile to the following, which worked fine and the file quality/size is definitely picking the different formatting options

var im = new mapnik.Image(256, 256);
map.render(im, (err, im) => {
   if (err) throw err;
   im.save(filePath,  "webp:quality=30"); 
}

@artemp
Copy link
Member

artemp commented Aug 26, 2020

@jonshutt 👍

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

No branches or pull requests

3 participants