sixlabors / imagesharp Goto Github PK
View Code? Open in Web Editor NEW:camera: A modern, cross-platform, 2D Graphics library for .NET
Home Page: https://sixlabors.com/products/imagesharp/
License: Other
:camera: A modern, cross-platform, 2D Graphics library for .NET
Home Page: https://sixlabors.com/products/imagesharp/
License: Other
From @Schaussi on September 7, 2016 8:11
Unfortunately, I have not found a way to do this yet.
Does a method like Graphics.DrawImage() exist in ImageProcessorCore?
E.g. it would be great if something like this would work:
using (Graphics g = Graphics.FromImage(_resultImage)) { g.DrawImage(_otherImage, x, y); }
Thank you
Copied from original issue: JimBobSquarePants/ImageProcessor#470
From @PromontoryProtean on January 28, 2016 6:40
I've been doing some prototyping on middeware for V3. I decided to keep it simple and build a basic thumbnail middleware. I layered it on top of the file manager web app that I have been porting to asp.net core. My repository is here:
https://github.com/PromontoryProtean/AspnetCoreFileManager
It is a basic file manager app (with some quirks to iron out) that has a tile mode that shows thumbnails for images you can upload. I built text file logging into the middleware to benchmark processing times and log exceptions. I learned a couple of interesting things from doing this. First the performance of resizing pngs is really good. I am seeing resize times generally around half a second. Jpgs have the issues we discussed in the performance thread, and I typically ran into memory errors when there were more than 3 large jpgs in a single directory. But for non-jpgs performance has been very good so far.
I took a very simple approach with generating the thumbnails and I am serving them via a memory stream rather than caching them to disk. I was going to try to build a basic cache, but after looking through V2 I wasn't sure what you had in mind for V3 equivalents for IGraphicsProcessor and IWebGraphicsProcessor. Is the general idea to use the Resampler class and/or IResampler? Or are you planning to introduce a new type of interface? I'm assuming the API is still very much in flux, so I'm just wondering what you have in mind for changes to the web apis.
Anyway, hopefully some of this will be useful for ImageProcessor.Web. I hope to help out more directly once I understand the structure and the new APIs a bit more.
Copied from original issue: JimBobSquarePants/ImageProcessor#312
Docs are available at:
https://sixlabors.github.io/docs/
From @JimBobSquarePants on January 13, 2016 0:43
I would like to create documentation like the following:
MS are using the library below but I can't seem to follow the instructions.
http://dotnet.github.io/docfx/
Copied from original issue: JimBobSquarePants/ImageProcessor#297
From @gdoron on October 31, 2016 12:57
Hi James @JimBobSquarePants,
This specific image:
fails when trying to load it.
Stacktrace:
ImageProcessorCore.Formats.JpegDecoderCore+EOFException: Exception of type 'ImageProcessorCore.Formats.JpegDecoderCore+EOFException' was thrown.
at ImageProcessorCore.Formats.JpegDecoderCore.Fill()
at ImageProcessorCore.Formats.JpegDecoderCore.ReadByte()
at ImageProcessorCore.Formats.JpegDecoderCore.ReadByteStuffedByte()
at ImageProcessorCore.Formats.JpegDecoderCore.EnsureNBits(Int32 n)
at ImageProcessorCore.Formats.JpegDecoderCore.DecodeHuffman(Huffman huffman)
at ImageProcessorCore.Formats.JpegDecoderCore.Refine(Block b, Huffman h, Int32 zigStart, Int32 zigEnd, Int32 delta)
at ImageProcessorCore.Formats.JpegDecoderCore.ProcessStartOfScan(Int32 n)
at ImageProcessorCore.Formats.JpegDecoderCore.Decode[TColor,TPacked](Image2 image, Stream stream, Boolean configOnly) at ImageProcessorCore.Image
2.Decode(Stream stream)
at ImageProcessorCore.Image2.Load(Stream stream) at Yooocan.Logic.ImageLogic.Resize(Stream stream, Int32 quality, Nullable
1 width, Nullable`1 height)
Any clue?
By the way, checkout this story: https://yooocan.com/Story/329/Having-Wheels-Has-Its-Perks
Amazing people, and you're helping them James!
THANKS A LOT!
Copied from original issue: JimBobSquarePants/ImageProcessor#505
ImageMagick has a very useful โautolevelโ feature that my company has used to good effect. It would be very cool if ImageSharp had such a feature.
Thank you!
i've been trying to resize (with cropping) some images to a fixed width of 350 and height of 150 with the following code.
using (var output = new FileStream("output.jpg", FileMode.Create))
{
Image image = new Image(file.OpenReadStream()); //file is a IFormFile object
image.Resize(new ImageSharp.Processing.ResizeOptions()
{
Mode = ImageSharp.Processing.ResizeMode.Crop,
Size = new Size(350, 150)
}).SaveAsJpeg(output, 90);
}
some of the resulting images are 150 wide and 350 height. which is not the result i'm expecting.
how do i get the resulting image to be 350 wide and 150 height no matter what orientation the source image is in?
using 1.0.0-alpha1-00038
from myget with .net core web api project.
some stats:
1.) source image 640w X 1136h => results in 350w X 150h [correct]
2.) source image 750w X 1334h => results in 350w X 150h [correct]
3.) source image 1334w X 750h => results in 150w X 350h [wrong]
4.) source image 960w X 1280h => results in 150w X 350h [wrong]
5.) source image 2448w X 3264h => results in 150w X 350h [wrong]
what's weird is that if i open one of the [wrong] images above in photoshop and export as jpg, imagesharp manages to produce the correct result.
check this zip file for a sample image that fails. and also the photoshop exported version of the same image which works.
From @Bartmax on September 6, 2016 0:50
When resizing multiple big images on aspnet core i usually get:
The specified CGI application encountered an error and the server terminated the process
is there anything I can do to mitigate this?
Copied from original issue: JimBobSquarePants/ImageProcessor#467
From @JimBobSquarePants on August 4, 2016 6:15
This issue serves to collect various issues with the image codecs. Additional issues will be added upon identification.
Png
Jpeg
Tiff
Copied from original issue: JimBobSquarePants/ImageProcessor#446
Is this the replacement for ImageProcessor.Core?
I installed this using nuget and it states it is version 0.0.0.0
Before, I would reference it with Using ImageProcessor but this reference doesn't appear to work?
png's are encoded incorrectly on version v1.0.0-alpha-000053 and higher (including 57)
last know good version is v1.0.0-alpha-000052
so i think something went wrong in this commit f814dc3
k so after version v1.0.0-alpha-000053 the error's get really obvious (weird colored blocks)
but before that some images are still encoded incorrectly (getting chopped off) and smaller resize actions turning into black images
currently checking how far back this starts occuring
I resize image
Origin: https://drive.google.com/file/d/0B7jXXO3qQiaRMmxJeXltdDRfeDg/view?usp=sharing
Resize on window: https://drive.google.com/file/d/0B7jXXO3qQiaRUlZ6cndXODJZdXM/view?usp=sharing
Reseze on centos 7: https://drive.google.com/file/d/0B7jXXO3qQiaRdGV1VVNsaVBrc3M/view?usp=sharing
On window Image not broken pixels but on centos 7 Image broken pixels
I using "Neostore.ImageSharp": "1.0.0"
And here is my code
Image imageOrigin = ImageFromFile(originFile);
int sourceWidth = imageOrigin.Width;
int sourceHeight = imageOrigin.Height;
ResizeMode mode = ResizeMode.Crop;
if ((width > sourceWidth) || (height > sourceHeight) || width <= 0 || height <= 0)
{
float nPercentW = 0;
float nPercentH = 0;
if (width > 0 && height > 0)
{
nPercentW = ((float)width / (float)sourceWidth);
nPercentH = ((float)height / (float)sourceHeight);
if (nPercentW < nPercentH)
{
height = (int)(sourceHeight * nPercentW);
}
else
{
width = (int)(sourceWidth * nPercentH);
}
}
else if (width <= 0)
{
width = (int)(sourceWidth * nPercentH);
}
else if (height <= 0)
{
height = (int)(sourceHeight * nPercentW);
}
mode = ResizeMode.Min;
}
using (FileStream output = File.OpenWrite(newFile))
{
ResizeOptions options = new ResizeOptions()
{
Size = new Size(width, height),
Mode = mode
};
imageOrigin.Resize(options).Save(output);
}
I resize to Width = 900 and Height =0
Please help me.
Thank
From @KLuuKer on August 18, 2016 20:15
Great library!
Also good that you are supporting EXIF data but....
I would like to completely skip the processing of EXIF (and any other non relevant metadata) and also not include it in the final output.
Because I am processing\downscaling\compressing images for use on a public facing website and nobody needs to see the EXIF data anyway.
This question was bound to show up :)
Copied from original issue: JimBobSquarePants/ImageProcessor#458
Add support for a 'Gradient brush'
Place to start for anyone wanting to contribute would be to look at the other brush implementations inside the ImageSharp.Drawing
project.
I would be nice if this supported both radial and linear gradients probably as 2 different brushes, one for each.
Features wanted;
We want to drop the hard dependency on the Clipper.cs source file so we need to port across the code and try to add any optimisations as we go (use Vector2
instead of IntPoint
etc) to prevent the need for copying the data structures around.
food for thought: could LinkedList<Vector2>
s be used instead of List<IntPoint>
as a fist optimisation?
I'm currently testing out this library to use in my future web app.
It works great for most images but some jpeg images don't open properly. Please check out the attached image. While I can open it in any program, ImageSharp returns 0 for height and width. (I hope Github does not alter the file in any way when uploading it)
I'm on 1.0.0-alpha1-00049, .NET Core 1.1.0. An image I'm testing with (attached) is throwing the below exception when I call var image = new Image(stream);
. All other images I've tested work properly, but I'm not sure what's happening with this one.
(In case GitHub altered it, I've uploaded the image here.)
Exception:
EOFException: Exception of type 'ImageSharp.Formats.JpegDecoderCore+EOFException' was thrown.
My code:
[HttpPost]
public async Task<IActionResult> Upload(IFormFile image)
{
using (var stream = new MemoryStream())
{
await image.CopyToAsync(stream);
// image verification, stream variable is not touched/used
stream.Seek(0, SeekOrigin.Begin);
StripExif(stream);
// do stuff
}
return Ok();
}
public static void StripExif(Stream stream)
{
// exception thrown here
var image = new Image(stream);
stream.Seek(0, SeekOrigin.Begin);
if (image.ExifProfile == null)
return;
// a ton of these follow
image.ExifProfile.RemoveValue(ExifTag.GPSLatitude);
// ...
image.Save(stream);
stream.Seek(0, SeekOrigin.Begin);
}
Beginning of stack trace:
ImageSharp.Formats.JpegDecoderCore+EOFException: Exception of type 'ImageSharp.Formats.JpegDecoderCore+EOFException' was thrown.
at ImageSharp.Formats.JpegDecoderCore.Decode[TColor](Image`1 image, Stream stream, Boolean configOnly)
at ImageSharp.Formats.JpegDecoder.Decode[TColor](Image`1 image, Stream stream)
at ImageSharp.Image`1.Decode(Stream stream)
at ImageSharp.Image`1.Load(Stream stream)
at [removed].StripExif(Stream stream) in [removed]\UploadHelpers.cs:line 39
at [removed].ImagesController.<Upload>d__5.MoveNext() in [removed]\ImagesController.cs:line 66
I updated from 1.0.0-alpha-000075 to 1.0.0-alpha-000195, and noticed that animated gifs seem to now have issues. I have done tests with a couple of images and see similar problems with both: black square artifacts on some frames of the gif.
I have been reproducing the issue by simply resizing the image
new Image(inStream)
.Resize(300,0)
.Save(outStream);
Currently we lack support for reading/writing ICC color profiles within Jpeg.
This directly negatively affects the color conversion process that we use for converting YCCK or CMYK jpeg images and prevents us from supporting DCI-P3
Reading in C# should be achievable using code based on Drew Noakes MetaDataExtractor (Apache 2.)
We'll have to additionally figure out how the conversion process takes place. there's info in WikiPedia but it's limited. @antonfirsov Could you possibly have a dig around libjeg-turbo and see if you can find how it's dealt with there? - My C is poor so I struggle to follow that codebase.
We probably don't need the ability to write a profile, just to store it within the image @dlemstra Perhaps we can work in your plan to store different profiles here?
Please comment below on your thoughts everyone.
At present we have to pass many options to the codecs as parameters. There is also ambiguity over what exactly "Quality" means - Sometimes it's color count, sometimes compression.
We need to:
Quality
property from Image<TColor, TPacked>
Image<TColor, TPacked>
that allows passing a specific decoder or decoders with options.Hello guys.
I have problem on facebook. When i sharing gif image which is resized in ImageSharp image doesnt loop and stopping.
Does Image class support 8-bit grayscale images? I mean read, write and convert from other color depths
Hi I am using this library to crop sections out of a larger image. Thousands of them. Every so often it hits an image I try to crop and I get this error
Unhandled Exception:
Unhandled Exception:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at ImageSharp.Processors.CropProcessor`2.<>c__DisplayClass0_1.<Apply>b__0(Int32 y)
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()
at System.Threading.Tasks.TaskReplicator.Replica.<>c.<.ctor>b__4_0(Object s)
at System.Threading.Tasks.Task.Execute()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
at System.Threading.ThreadPoolWorkQueue.Dispatch()System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at ImageSharp.Processors.CropProcessor`2.<>c__DisplayClass0_1.<Apply>b__0(Int32 y)
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()
at System.Threading.Tasks.TaskReplicator.Replica.<>c.<.ctor>b__4_0(Object s)
at System.Threading.Tasks.Task.Execute()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
at System.Threading.ThreadPoolWorkQueue.Dispatch()System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at ImageSharp.Processors.CropProcessor`2.<>c__DisplayClass0_1.<Apply>b__0(Int32 y)
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()
at System.Threading.Tasks.TaskReplicator.Replica.<>c.<.ctor>b__4_0(Object s)
at System.Threading.Tasks.Task.Execute()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
Based on CropProcessor
I assume it is when cropping not when reading the image. My pseudo code is like this
for each image in images // there is > 10,000
image = new Image(path)
for each section in sections // from another file I load, basically bounding boxes within the image
image.Crop(...).Save(newFilePath)
Thanks
The library will at some point need to add font support.
Libraries to consider basing the system on.
Ideally we shouldn't have any dependencies and absolutely no unmanaged dependencies as we need to deploy easily on web applications.
From @JimBobSquarePants on December 1, 2015 12:29
More a nice to have than anything but I believe that if we are to do this properly we shouldbe able to convert where possible between different color spaces.
Currently we have the following.
Inspiration could be taken from the following:
http://colormine.org/
https://github.com/scijs/color-space
Copied from original issue: JimBobSquarePants/ImageProcessor#260
It would be great to have the ability to blend colors based on the W3c specification.
http://www.w3.org/TR/compositing-1/#blending
Additional blend modes can be added as static methods on ColorSpacialTransforms in ColorSpacialTransforms.cs
Blend Modes:
From @JimBobSquarePants on March 16, 2016 9:44
We've got a pretty good feature set for a V1 release.
Now we need to make it fast.
Things to look at:
ArrayPool
, Slice<T>
For benchmarking we can use BenchMarkDotNet now that the prerelease supports CoreFX
Add your thoughts below.
Copied from original issue: JimBobSquarePants/ImageProcessor#347
Please integrate xamarin support out of the box.
From @JimBobSquarePants on December 1, 2015 12:23
The new System.Numerics.Vectors
contains several new types that take advantage of SIMD processors and are specifically designed graphics programming. I have little-to-no knowledge of those types and will need assistance integration the various methods they offer in order to utilize them properly.
Copied from original issue: JimBobSquarePants/ImageProcessor#259
png's are decoded incorrectly on version v1.0.0-alpha-000062 and higher (including 95)
last know good version is v1.0.0-alpha-000061
so i think something went wrong in this commit 27522da
i think it's the same as #24 but this time it's in the decoder, i only have 1 specific image that gives me the issue. all of my other images decode&encode just fine (on version 95)
tested with output format: png,jpeg,bmp,gif (all give the same issue)
used the same simple console app as in #24 (comment)
please don't forget to sleep this time ๐
Hey everyone! I've been working on getting rid of our build warnings - stylecop and compiler.
There are 3 categories of warnings left, and I need your help on deciding how to fix those ๐
1. SA1649 - File name must match first type name (4)
This is happening for all classes where we have a generic version and a regular version which share the same name - Brushes, ImageBrush, etc. and we use the convention of {name}`{numberOfTypes}.cs
for the file name.
The options I see are:
I would personally like a better distinction between the T and non T versions, and that would also help with the readability of the code.
2. SA1401 - Field must be private (4)
This is happening in JpegDecoderCore
only, where we have some internal fields, like below.
/// <summary>
/// The byte buffer.
/// </summary>
internal Bytes Bytes;
This is a maintainability rule - the best practice is to keep all fields to private, and if anything needs to be exposed it should be done via properties.
Should we change these fields to properties? I'm not very familiar with this code so I'm hoping you will have more reasons for one option or the other.
3. CS0219 - The variable <> is assigned but its value is never used (4)
This is in the test project in ReferenceImplementations
. r0 and r4 variables are never used. The fix to remove them is trivial, but I was wondering if them not being used is actually intentional.
From @Bartmax on May 6, 2016 4:25
When using a Png file I get this error:
ImageProcessorCore.ImageFormatException: Interlacing is not supported
some png works but some doesn't.
The code is here:
https://github.com/JimBobSquarePants/ImageProcessor/blob/abbf63f863635d4df1a04d322eccd425db7e82db/src/ImageProcessorCore/Formats/Png/PngDecoderCore.cs#L385
What does this mean? is this a limitation of the library or am I doing something wrong or a bug?
Copied from original issue: JimBobSquarePants/ImageProcessor#379
From @KvanTTT on April 26, 2015 13:33
There is managed implementation of CAIR seam carving (content-aware) algorithm: Seam-Carving-Advanced.
It it possible to port it to your library. Is it necessary?
Copied from original issue: JimBobSquarePants/ImageProcessor#158
We need to add implementations for the following MonoGame classes and tests to match.
Part of Wayland development is that I create a Shared Memory Buffer that is being used between processes and I wanted to eliminate the amount of buffer copying between ImageSharp and Shared Memory Buffer. If implemented, we may actually be able to see a relatively fast User Interface on Linux for C# that is easy to use for everyone.
Can ImageSharp implement a safe api that accepts IntPtr for Argb or other image format pixel buffer? (Width/height/strides can be provided if needed.)
Please and thank you
Most of our discussions are happening below separate issue/PR topics now. With the current team activity it seems to be more efficient to me, so I decided to open an issue for this topic, hope it's fine.
I think if we want a performance-aware team, everyone should (must!) be able to profile code. We can't wait for better netcore tooling, we need it now!
It's actually very easy with a classic .NET project referencing ImageSharp as a .NET 4.6 dll. With MSBUILD <Link>
it's possible to construct such a project adding just ~5 files!
Why don't have it on the common master branch? :)
From @JimBobSquarePants on August 31, 2016 1:49
We should be able to support TIFF
Useful links.
http://partners.adobe.com/public/developer/tiff/index.html
http://www.remotesensing.org/libtiff/
http://www.awaresystems.be/imaging/tiff.html
Current implementation can be found in the tiff-codec branch.
I have image (png) export from powerpoint
When i resize image broken
And this is my code
Image imageOrigin = ImageFromFile(originFile);
ResizeMode mode = ResizeMode.Min;
using (FileStream output = File.OpenWrite(newFile))
{
ResizeOptions options = new ResizeOptions()
{
Size = new Size(600, 0),
Mode = mode,
};
imageOrigin.Resize(options).Save(output);
}
I using last code download from https://codeload.github.com/JimBobSquarePants/ImageSharp/zip/master (01/12/2017)
"version": "1.0.0-alpha1-*"
reduce the contrast of the image
Please help me
Hi,
It looks like there's no interpolation happening for rotation - can I add that in as a feature request? The quality of images, when rotated by arbitrary degrees, are quite poor.
Thanks,
I have a background image of lets say 1000 x 600
pixels and a smaller overlay image of 128 x 80
pixels.
the desired outcome
What I need to do is produce an output image by placing the ovelay.jpg on the background.jpg at the x,y coordinates.
what I've tried so far
The following takes the overlay to the middle of the larger background image. I cannot seem to find how to affect the positioning using the x,y offsets.
using (var backgroundStream = StreamExtentions.GetImageStream("scene_bg.jpg")) {
var outPath = @"c:\temp\output.jpg";
using (var output = File.OpenWrite(outPath)) {
var background = new Image(backgroundStream);
var overlay = default(Image);
using (var overlayStream = StreamExtentions.GetImageStream("overlay.png")) {
overlay = new Image(overlayStream);
}
var opacity = 100;
var x = 0;
var y = 0;
var result = overlay.Pad(background.Width, background.Height);
background .Blend(result, opacity)
.SaveAsJpeg(output);
}
}
Is this possible at the moment?
I noticed the unit test suite of the project takes about 4 mins to run, which is pretty slow for unit tests.
Martin Fowler has some recommendations here on unit testing speed, but generally one test should be in the range of milliseconds and the suite in seconds.
We can look into how to speed them up, maybe we can move some expensive initialization. Currently there are 119 tests which run for more than 1s, here's the breakdown.
Hi,
decoding from a memory stream fails if the stream position is already at EOF.
In example:
Stream zipStream = ... // get a zipped jpeg
MemoryStream unzippedStream = new MemoryStream();
await zipStream.CopyToAsync(unzippedStream);
Image image = new Image(unzippedStream);
Code above fails with a NotSupportedException "Image cannot be loaded. Available formats: ..." because Image.Decode() find an empty header (Image{TColor].cs line 447) calling stream.Read() at EOF.
The following works:
Stream zipStream = ... // get a zipped jpeg
MemoryStream unzippedStream = new MemoryStream();
await zipStream.CopyToAsync(unzippedStream);
unzippedStream.Position = 0; // add this to reset stream position
Image image = new Image(unzippedStream);
I think Image constructor should set Stream.Position = 0 when decoding images from streams.
The binary packages targeting the full .NET framework (net45) depend on System.Numerics.Vectors 4.1.1.0, which is from the CoreFX. While it's possible to work around that with an assembly redirect, it shouldn't be necessary.
I'm using 1.0.0-alpha1-00048, .NET Core 1.1.0. I'm unable to load any images whatsoever. Every single image I try returns this exception:
NotSupportedException: Image cannot be loaded. Available formats:
-ImageSharp.Formats.PngFormat
-ImageSharp.Formats.JpegFormat
-ImageSharp.Formats.GifFormat
I'm manually checking the stream to ensure it's a valid image, and I know they're being handled properly because I ultimately upload to AWS and the files are exact matches. Not sure what's going on. I can provide sample images if you'd like, but it's happening with every one of the 10+ images I tried (random images that happen to be on my computer, all either .jpg, .png, or .gif).
Code:
[HttpPost]
public async Task<IActionResult> Upload(IFormFile image)
{
var verify = UploadHelpers.VerifyImageUpload(image);
if (verify != string.Empty)
return BadRequest(verify.ToGenericErrorJson());
Image result = null;
using (var stream = new MemoryStream())
{
await image.CopyToAsync(stream);
UploadHelpers.StripExif(stream);
result = await _imgSvc.UploadImageAsync(stream, User.Id,
Path.GetExtension(image.FileName).ToLower(), image.ContentType);
}
// do some stuff
return Ok();
}
public static void StripExif(Stream stream)
{
// exception thrown here
var image = new Image(stream);
// strip Exif tags
}
ImageSharp should be split into multiple projects so you only have to pay for what you need.
All packages will live in there own namespaces except the various formats that will share the ImageSharp.Formats
namespace.
All extension methods targeting Image<TColor>
will live in the global ImageSharp
namespace no matter which project they belong to.
All packages to be versioned and release together under a common version number thus if a change happens in This is likely to not be the case TBCImageSharp.Formats.Gif
then ImageSharp.Drawing
version number will be bumped so that all packages from a single build will have a single common number.
origin discussion here: https://gitter.im/ImageSharp/General?at=584378420da034021b65da62
This is all open to discussion and this issue is here to permanently capture any decisions made around this.
EDIT: Updated based on feedback.
From @JimBobSquarePants on September 21, 2016 11:26
I'd like to find a way I can add dithering to the various quantizers.
See the following for inspiration. Ideally we would be able to pick from multiple algorithms.
http://www.codeproject.com/Articles/66341/A-Simple-Yet-Quite-Powerful-Palette-Quantizer-in-C
Copied from original issue: JimBobSquarePants/ImageProcessor#474
I'm having an issue where my original jpg of quality 90 (photoshop thing) is resized it gets a worse quality than if I resize in photoshop.
Is there anyway to improve this or maybe I'm missing to set the quality properly?
From @JimBobSquarePants on December 1, 2015 12:48
This issue wraps several brush types.
I think we should implement at least:
I'm envisioning something like :
PathBrush brush = new PathBrush
{
Color = Color.Black,
Thickness = 10, // the thickness to draw a line
Path = vectors // A list of vectors to follow
}
Image.Draw(brush)
The method would draw a Bezier curve following the given path, color, and thickness.
Copied from original issue: JimBobSquarePants/ImageProcessor#264
Add support for the following shapes
There are 2 path to follow adding these the optimised or unoptimised route;
Polygon
class to handle.IShape
and IPath
required.You are required to convert down to a point array anyway for things like ComplexPolygon
to work thus its probably worth doing these as 2 passes;
Polygon
(which is built for arbitrary shaped polygons).IShape
and IPath
methods/properties to avoid Polygon
as use shape specific logic that can be calculated more efficiently.Hi I'm using this file as the input:
You probably allready are aware of that but with System.Drawing it takes on avg: 300ms and with ImageSharp arround 1300ms. Anyway to speed it up?
I also noticed a considerable difference in the resized image.
Done with System.Drawing with these settings:
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
This is the result from System.Drawing:
With ImageSharp
var im = new Image(stream);
im.Resize(1300, 866, new BicubicResampler()).Save(targetStream);
It looks like the ImageSharp Resized image contains a bit more green. And the filesize is 64kb bigger then the System.Drawing example. I get comparable results with other samplers.
Am I doing something wrong. Is this as designed?
PS: ImageMagick (Magick.Net or Node.JS) and OpenCV return a result very similar to System.Drawing.
Hello,
Could you help me please?
I want to use your package in my project but I don't know how to set my project to download packages from MyGet gallery.
I'm using Visual Studio 2015 but my server is linux so it's necessary my server be able to download your package using "dotnet restore" from the linux.
Thanks in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.