mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
34 lines
1.5 KiB
Plaintext
34 lines
1.5 KiB
Plaintext
<h1>Image Resizing</h1>
|
|
|
|
<p>
|
|
This sample shows how the NPM module <a href="https://www.npmjs.com/package/sharp"><code>sharp</code></a>
|
|
can be used for dynamic image resizing from within an ASP.NET Core application. There is one copy of the
|
|
following image on disk, but we can set up an MVC action method that returns it resized to fit within an
|
|
arbitrary width and height.
|
|
</p>
|
|
|
|
<p>
|
|
<strong>Dependencies:</strong> On Windows and Linux, there are no native dependencies. Just running
|
|
<code>npm install</code> is enough. On OS X, however, you need to have <code>libvips</code> installed,
|
|
which you can get through <a href="http://brew.sh/">Homebrew</a> by running
|
|
<code>brew install homebrew/science/vips</code>.
|
|
</p>
|
|
|
|
<p>
|
|
<em><a href="https://www.flickr.com/photos/dcoetzee/3572948635">Parrot</a>
|
|
by <a href="https://www.flickr.com/photos/dcoetzee/">D Coetzee</a>
|
|
is dedicated to the <a href="http://creativecommons.org/publicdomain/zero/1.0/">public domain (CC0)</a></em>
|
|
</p>
|
|
|
|
<h3>100px wide [<a href="/resize/images/parrot.jpg?maxWidth=100">open</a>]</h3>
|
|
<img src="/resize/images/parrot.jpg?maxWidth=100" />
|
|
|
|
<h3>200px wide [<a href="/resize/images/parrot.jpg?maxWidth=200">open</a>]</h3>
|
|
<img src="/resize/images/parrot.jpg?maxWidth=200" />
|
|
|
|
<h3>400px wide [<a href="/resize/images/parrot.jpg?maxWidth=400">open</a>]</h3>
|
|
<img src="/resize/images/parrot.jpg?maxWidth=400" />
|
|
|
|
<h3>800px wide [<a href="/resize/images/parrot.jpg?maxWidth=800">open</a>]</h3>
|
|
<img src="/resize/images/parrot.jpg?maxWidth=800" />
|