Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 12:41
    JimBobSquarePants edited #1062
  • 12:38
    JimBobSquarePants commented #1062
  • 12:33
    codecov[bot] commented #1062
  • 12:33
    codecov[bot] commented #1062
  • 12:33
    JimBobSquarePants synchronize #1062
  • 12:33

    JimBobSquarePants on smart-non-generic-api

    Revert non-generic decode to us… Simplify format specific metada… (compare)

  • 05:13
    JimBobSquarePants commented #1062
  • Dec 12 22:50
    xfischer commented #204
  • Dec 12 13:31
    antonfirsov commented #1061
  • Dec 12 13:22
    antonfirsov commented #1062
  • Dec 12 13:20
    antonfirsov commented #1062
  • Dec 12 12:23
    JimBobSquarePants review_requested #1062
  • Dec 12 12:23
    JimBobSquarePants review_requested #1062
  • Dec 12 12:23
    JimBobSquarePants review_requested #1062
  • Dec 12 12:14
    codecov[bot] commented #1062
  • Dec 12 12:12
    codecov[bot] commented #1062
  • Dec 12 12:12
    codecov[bot] commented #1062
  • Dec 12 10:54
    JimBobSquarePants commented #1061
  • Dec 12 10:37
    JimBobSquarePants commented #1062
  • Dec 12 10:35
    JimBobSquarePants commented #1061
Vicente Penades
@vpenades
I partially agree.... the current API is very powerful, as long as you know what kind of image are you loading. Let's suppose you want to resize a bunch of images in a directory, and you have a mix of rgba32, gray16 and maybe other exotic formats..... a blind loop would just load all the images to rgba32. Maybe a Image.LoadAndPreservePixelFormat("filename.png"); would be in order...
Peter Amrehn
@jongleur1983
and there are quite some operations that are semantically pixel type agnostic: resize, extracting parts of the image and stuff like that.
Mike Küster
@Xantiva_gitlab
Thats sound good. The other question is: Why are other programs not able to open such a file in the correct format? I don't know - is there any "gold standard" program for testing this?
James Jackson-South
@JimBobSquarePants

How would you suggest aliasing the generic type? You can’t do that without overloads for each pixel format.

The smarter thing to do for now is use the provided API to load the format and metadata only via Identify and choose the exact right layout for the given image based on that information

Peter Amrehn
@jongleur1983
@JimBobSquarePants isn't every Image<TPixel> an Image as well? Load would just return the result as an Image; if you need an Image<Rgba32>, use Load<Rgba32>() instead. Let's provide a way to identify the pixel type of Image (I guess that exists already?). So the result of Load() can be cast savely
James Jackson-South
@JimBobSquarePants

@jongleur1983 It ould be a fair amount of work though adding the behavior to each format.

@Xantiva_gitlab I have no idea what you mean by "gold standard"

Mike Küster
@Xantiva_gitlab
gold standard - if you create a new scientific method, you would compare your method against a well-established, approved method: the "gold standard" ... ;)
James Jackson-South
@JimBobSquarePants
But what are you comparing?
Mike Küster
@Xantiva_gitlab
The correctness of a png file format?
James Jackson-South
@JimBobSquarePants
Our correctness is gold standard in that regard
You're conflating the API with pixel accuracy.
James Jackson-South
@JimBobSquarePants

@jongleur1983 @vpenades OK.... Just did some experimenting with the jpeg decoder. I think this is possible and not too difficult, we just need to do some code shuffling.

@Xantiva_gitlab Could you please raise an issue in the repository. I can't promise this will happen soon but if an issue is there at least anyone could take a look.

James Jackson-South
@JimBobSquarePants
Gonna end up with a frustrating amount of code duplication parsing the png stream though. The order of critical chunks is not specified other than IHDR so we have to copy the entire image loop code into two methods. That's gonna trigger the old OCD!
We also do not have dedicated pixel formats for Gray8Alpha or Gray16Alpha so cannot return the correct format for them.
James Jackson-South
@JimBobSquarePants
Don't like the name Gray8Alpha tbh, regret giving Gray8 the name it has. All other pixel formats use 1 letter per component. Alpha8 also... shakes head.
Maybe Ga16 since it would have 8 bits per component. Ga32 for the 16bit equivalent.
Peter Amrehn
@jongleur1983
:) but G is Green, isn't it, so it could be HL16 (L for lightness, capital here for readability, although it'd be Hl16 in fact)
sorry: La then, right?
La16
James Jackson-South
@JimBobSquarePants
La16 yeah, that is more technically correct... :smile: Man I really wanna rename the Gray_X types now but I don't think I could get away with it.
Vicente Penades
@vpenades
I vote for La16
James Jackson-South
@JimBobSquarePants
So GrayX to Luminance_X then? Or rename Alpha8 and GrayX to A8 and LX?
Peter Amrehn
@jongleur1983
well, we have RGBA for Red, Green, Blue, Alpha. I'd propose to introduce "L" for "luminance <=> Gray", so it would be A8 and L{x}, yes
James Jackson-South
@JimBobSquarePants
Sounds good. It'll take me a while to put all this plus tests together...
Mike Küster
@Xantiva_gitlab

I tried to use Identify ...

            var image16Bit = Image.LoadPixelData<Gray16>(byteArray, 256, 256);
            var pngEncoder = new PngEncoder()
            {
                BitDepth = PngBitDepth.Bit16,
            };
            image16Bit.Save(@"C:\Temp\test-imagesharp-16bit.png", pngEncoder);
            using (var stream = File.Open(@"C:\Temp\test-imagesharp-16bit.png", FileMode.Open))
            {
                var info = Image.Identify(stream);
            }

info.PixelType.BitsPerPixel = 64

I would expect 16 ...

James Jackson-South
@JimBobSquarePants
You shouldn't... You never set the ColorType property.

https://docs.sixlabors.com/api/ImageSharp/SixLabors.ImageSharp.Formats.Png.PngEncoder.html#SixLabors_ImageSharp_Formats_Png_PngEncoder_ColorType

If you were decoding an actual png rather than just encoding pixel data the library would preserve the metadata and automatically set the correct values.

James Jackson-South
@JimBobSquarePants
Mike Küster
@Xantiva_gitlab
Ok, thank you. If I set the ColorType of the encoder to Grayscale I got the 16 as you said.
But with that option I can work. Maybe you can just add this info to the Image.Load command? "Load uses always RGB32, if you need to know the real type, use Identify ..."
James Jackson-South
@JimBobSquarePants
I’ve literally just had a conversation in this forum and shared progress where we work out the correct pixel format. You did make the effort to read all that didn’t you?
Bobbahbrown
@bobbahbrown
Is it possible to generate an MD5 or some other hash from an image to identify copies of it natively? Apologies if it is a straightforward question, I have not done it before.
Sergio Pedri
@Sergio0694
@bobbahbrown What about just computing the MD5 on the image files? The fact that a file is an image doesn't really matter there, you'd just be treating it as a binary blob. Unless you were thinking of something else? 🤔
Bobbahbrown
@bobbahbrown
Well I was fixing to identify constituent regions of a file
so between multiple files having the differences identified initially by a comparison of hashes
as only specific regions will change and I'm only interested in those specific regions
Nikolai Herbstritt
@autumnride_twitter
Hi there, is there a way to use OTF fonts at all? Getting an error that only TTF is supported.. :(
James Jackson-South
@JimBobSquarePants
Not yet. Woff and TTF only
Nikolai Herbstritt
@autumnride_twitter
Ok thanks.
James Jackson-South
@JimBobSquarePants
Once I get ImageSharp released I want to help @tocsoft with the Fonts library.
Nikolai Herbstritt
@autumnride_twitter
Nice!
Nikolai Herbstritt
@autumnride_twitter
Quick image related question. I am dynamically loading an image then scale it and then place it on a template. This is the an example image that I am loading:
image.png
Unfortunately the scaled and added image looks grainy.. Any tips for improving this please?
Nikolai Herbstritt
@autumnride_twitter
Minor quality loss for PNG, but major for GIF.. Is there a setting I am missing to get more colour or better quality for gif?
Nikolai Herbstritt
@autumnride_twitter
Update: Got a better result by setting the GifColorTableMode to Local. Is that be best solution?
James Jackson-South
@JimBobSquarePants

If it’s a single frame the giftable mode shouldn’t make a difference.

There’ll only be quality loss in png if you are saving it as a paletted image which reduces the color palette to 256 colors (same as gif)

With gif I’d try toggling dithering and using the WuQuantizer for color reduction.

James Jackson-South
@JimBobSquarePants
@autumnride_twitter Would it be possible to see some code? The png you've shared here is 32bit which is lossless and therefore confusing.
Nikolai Herbstritt
@autumnride_twitter
Hey, all good - PNG issue was something different and the GIF looks much better now that every frame has its own color table!! Cheers! Really appreciate the great support here!! 10/10
Nikolai Herbstritt
@autumnride_twitter
I feel like I am using all of your libraries functionality very soon.. haha. Is there a way to draw an image with a border? What I would like to achieve is take a square photo, make it to an round avatar (already done), but also give it a coloured border?!