StephanGeorg / staticmaps

A Node.js library for creating map images with markers, polylines, polygons and text.
MIT License
167 stars 49 forks source link

Allow resizing marker #56

Closed mohd-akram closed 1 year ago

mohd-akram commented 3 years ago

I'm using the map.addMarker() method and was surprised to find that the width and height parameters are for specifying the image's dimensions, instead of the desired size. It might make more sense to get that information directly from the image's metadata, and have the width and height parameters specify the desired output size on the map.

StephanGeorg commented 3 years ago

Hi @mohd-akram.

Yeah, sounds reasonable. Unfortunately I currently have no resources to work on that topic. Do you have and could you write a PR? Would be awesome.

swarnat commented 2 years ago

Look at #73 @mohd-akram If you like, you can test them already. I need to implement tests, before the merge request is ready

mohd-akram commented 2 years ago

I would urge to fetch the width and height automatically using sharp - there's no reason for the user to specify them since that data is in the image, and simply use the existing width and height parameters for resizing.

swarnat commented 2 years ago

The linked pull request now also is able to recognize the marker image size, when not set. Currently I think only the offset must recalculated. But OpenSource time is over, so I will do it later.

I also tried to remove the additional needed time, by reuse the sharp instance for metadata, resize and composite. For some reason the sharp library cannot composite with an instance of itself. But to convert a Buffer into sharp instance probably takes less time. I will check this with some tests.

StephanGeorg commented 1 year ago

73

StephanGeorg commented 1 year ago

Took a while but finally added. Thank you very much @swarnat for all your work.