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

adding freetype support and updating version of ImageMagick #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sw360cab
Copy link

@sw360cab sw360cab commented Jun 5, 2020

I think that it may be useful to achieve freetype engine support when dealing with fonts in images.
It is worthy since the library compile statically easily as libpng and libjpg and it does slightly increase the final archive.

I took the chance to update also the ImageMagick and libjpg version.
I tested and it compile smootly.

@karpet
Copy link

karpet commented Jul 20, 2020

I tried this branch but get an error about missing fonts when I try to use the layer in a lambda.

convert: unable to read font `helvetica' @ error/annotate.c/RenderFreetype/1392.
convert: non-conforming drawing primitive definition `text' @ error/draw.c/RenderMVGContent/4434.

is it possible ghostscript is also needed? My research suggests that type.xml must exist and point to actual font files on the system, and those seem to be part of gs.

@sw360cab
Copy link
Author

Hi,
are you sure you pointed the right path of Helvetica Font when launching the command?

I am unable to try right now. Let m know if you succeed in any way.

@karpet
Copy link

karpet commented Jul 21, 2020

Our existing code never makes explicit calls to set the font, so the helvetica must be a default of some kind.

Can you provide an example of setting the font path as you describe? I tried:

const gm = require("gm").subClass({ imageMagick: true }).font('Helvetica');

with no luck.

@karpet
Copy link

karpet commented Jul 21, 2020

ok I figured out I needed to make the .ttf file available and set it like:

gm.font("path/to/file.ttf")

works wonderfully -- thank you!

@RobTS
Copy link

RobTS commented Sep 1, 2020

Are there any plans to merge this in the near future?

@sw360cab
Copy link
Author

sw360cab commented Sep 2, 2020

@RobTS it would be nice for me. AFAIK there is not a lot of interest in having FreeType in the state of the art AWS Lambda Layer.
Btw if you want you can you use my layer (arn:aws:lambda:eu-west-1:797374828937:layer:image-magick-freetype:3) that is the exact fork of this supporting freetype.

@edjames
Copy link

edjames commented Oct 21, 2020

Btw if you want you can you use my layer (arn:aws:lambda:eu-west-1:797374828937:layer:image-magick-freetype:3) that is the exact fork of this supporting freetype.

Hi, and thanks for your work on this. I'm having trouble using this layer in my own app as I keep running into permissions problems like this:

not authorized to perform: lambda:GetLayerVersion on resource

My IAM profile has all the required permissions but still no luck. Do I have to "import" or "clone" this layer into my own account in order to use it?

@sw360cab
Copy link
Author

I tried to grant to all (*).
Give it a try.

@edjames
Copy link

edjames commented Oct 22, 2020

I tried to grant to all (*).
Give it a try.

Thanks @sw360cab. Unfortunately still no dice :(

User: arn:aws:iam::*********:user/******** is not authorized to perform: lambda:GetLayerVersion on resource: arn:aws:lambda:eu-west-1:797374828937:layer:image-magick-freetype:3 (Service: AWSLambdaInternal; Status Code: 403; Error Code: AccessDeniedException; Request ID: fad6777e-7094-4c80-9347-f66c9f139ce7; Proxy: null)

Is there any chance you have the zip file available? If so I would very much appreciate it.

@sw360cab
Copy link
Author

I would zip it. But I would be more happy if we are able to share it via AWS.
In which region are you publishing your Lambda? Because I tried to import the layer in a Lambda in another accout and It works like a charm, but the region is EU-WEST-1 (Ireland). If you are in another region I need to republish the layer there.

@edjames
Copy link

edjames commented Oct 22, 2020

Ah good point! I'm in EU-WEST-2.
Thanks mate!

@sw360cab
Copy link
Author

I will publish the layer there

@edjames
Copy link

edjames commented Oct 22, 2020

I will publish the layer there

👍 I will let you know if it works for me. Thanks very much.

@sw360cab
Copy link
Author

Give a try to this ARN:

arn:aws:lambda:eu-west-2:797374828937:layer:image-magick-freetype:1

@edjames
Copy link

edjames commented Oct 22, 2020

Awesome! That works.

I'm now stuck with a new error with fonts but I think this is ghostrscript:

montage: unable to read font `helvetica'

Ugh! Thanks for your help though.

@sw360cab
Copy link
Author

That should be just a matter of font path. Happy it worked almost out of the box

@Zelfapp
Copy link

Zelfapp commented Oct 27, 2020

I will publish the layer there

@sw360cab

Will you please publish to us-east-1? How do I include the specific font I want to use?

@edjames
Copy link

edjames commented Oct 27, 2020

That should be just a matter of font path. Happy it worked almost out of the box

Not sure how to control that though. When I check for available fonts using the below command it does show that Helvetica is available (not sure if this is case-sensitive):

identify -list font

Any help much appreciated.

@sw360cab
Copy link
Author

@Zelfapp
Here is the ARN for us-east-1
arn:aws:lambda:us-east-1:797374828937:layer:image-magick-freetype:1

@edjames

Have you tried using
convert with -font and the absolute path to font as .tff file?

AFAIK Helvetica is not free of download, it has a paid license.

@abishekaditya
Copy link

@sw360cab Can you share the zip file? I followed your method to create the layer but the symlink is not being created

@sw360cab
Copy link
Author

@abishekaditya tried by following this or this?

@abishekaditya
Copy link

yes, unfortunately both didn't work properly because of linking issues. so I ran imagemagick on an Amazon Linux 2 instance in cloud9 and saw which .so files were being accessed. Then I copied these files into /usr/lib/ folder and then it worked

@sw360cab
Copy link
Author

ok, Feel free to open a PR on my repo fork

@abishekaditya
Copy link

Sure. I was busy with other things till now. Have to work on this again, so will try to fix this

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

Successfully merging this pull request may close these issues.

6 participants