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

Pass image instead of path and height #11

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

JoshuaLampert
Copy link
Contributor

Thanks for the template! I wanted to try the recently added feature of adding an image (thanks @Orbion-J!), but struggled with including the image. It seems like typst searches for the image in the directory of moderner-cv, instead of the directory of the project, which uses moderner-cv. I get the following error:

error: file not found (searched at /home/lampert/.cache/typst/packages/preview/moderner-cv/0.1.2/picture.jpg)
   ┌─ @preview/moderner-cv:0.1.2/lib.typ:78:22
   │
78 │     let image = image(image-path, height: image-height)
   │                       ^^^^^^^^^^

Obviously, I don't want to put my image into this specific path, but rather in my project dir. Therefore, I propose to pass an image object instead of only the path. This also makes the image-height parameter obsolete as it is passed to the image function, which the user is now supposed to call.
What do you think?

@pavelzw
Copy link
Owner

pavelzw commented Jan 25, 2025

sounds good to me, any other opinions @Orbion-J?

@JoshuaLampert
Copy link
Contributor Author

Should we continue with this if @Orbion-J doesn't answer?

@Orbion-J
Copy link
Contributor

Orbion-J commented Feb 4, 2025

hey, sorry I did not answer sooner. That's actually a better idea to give an image object I think, thank you for that.
To avoid the error you had, you need to give a path that starts with / so that it searches at the root of the project and not in the template folder.

@JoshuaLampert
Copy link
Contributor Author

That's what I tried and gave me the error above.

@JoshuaLampert
Copy link
Contributor Author

Here is an MWE: https://typst.app/project/rW8SSglf9kWEOikQNLIR3r

@Orbion-J
Copy link
Contributor

Orbion-J commented Feb 5, 2025

Oh I see, that is a bit strange to me. Using a local import, I don't have such issue but with the @preview import it breaks yes. I'll try to understand what is going on and if a fix is possible.
But anyway, as I said, I think using image objects is better anyway so if this fixes this issue, let's go for it

@JoshuaLampert
Copy link
Contributor Author

Yes, I agree. If you are fine with it, let's just go with passing an image. Thanks for having a look @Orbion-J.

@pavelzw
Copy link
Owner

pavelzw commented Feb 5, 2025

Great! I'll create a release after taking a look at #14

@pavelzw pavelzw merged commit 8a82ec4 into pavelzw:main Feb 5, 2025
2 checks passed
@JoshuaLampert JoshuaLampert deleted the pass-image branch February 5, 2025 16:21
@JoshuaLampert
Copy link
Contributor Author

Thanks!

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.

3 participants