Redth / ResizetizerNT

Add SVG's and PNG's to your shared Xamarin Project
MIT License
318 stars 31 forks source link

Resize Downloaded Image #24

Closed TonyLugg closed 4 years ago

TonyLugg commented 4 years ago

Is there a way to resize an image downloaded from a web server at runtime?

Redth commented 4 years ago

Sure, you could create an msbuild task that runs before resizetizer which downloads the image at build time.

Something like this:

<Target BeforeTargets="ResizetizeCollectImages">
    <DownloadFile SourceUrl="https://mysite.com/image.svg" DestinationFileName="Images/image.svg" SkipUnchangedFiles="true" />
    <SharedImage Include="Images/image.svg" BaseSize="40,40" />
</Target>

The key will be to run BeforeTargets="ResizetizeCollectImages" to ensure your SharedImage item is added to the group before Resizetizer looks for them.

Of course you could get much fancier than that, but that should do the trick for the basic idea.

TonyLugg commented 4 years ago

No, it can't be done at build time. Customers can set custom logo/colors to brand the app for their company. The logo is downloaded when the app starts so it varies based on user. It would be nice to be able to download an image at runtime and have a library that would resize it for all resolutions/densities.

Redth commented 4 years ago

Ahh, sorry that's definitely out of the scope of this project.

TonyLugg commented 4 years ago

But it would be an awesome enhancement, hint, hint. 😉