mandykoh / prism Goto Github PK
View Code? Open in Web Editor NEWColour management for Go
License: MIT License
Colour management for Go
License: MIT License
TIFF is commonly used in RIP applications. There is a decoder for single image TIFF files in the extended Go library.
I'd volunteer - and I'll see if I can get to it - but the way my time is going right now I don't feel like I can commit to do this in any reasonable timeframe.
I'm working on a web server that processes user's image uploads. I'm trying to normalize the color space of the uploaded files (PNGs and JPEGs) from their source color spaces to sRGB. I see you have LineariseImage functions for several source color spaces, but I'm not sure the best way to detect the color space of the input image in order to call the appropriate function.
I can see that I'm able to parse the ICCProfile from the metadata and get a description from that - should I be switching on the description? Or is there a more reliable way to do this?
E.g. I'd like to do something like this:
md, imageStream, err := autometa.Load(reader)
if err != nil {
return nil, err
}
images, err := image.Decode(imageStream)
if err != nil {
return nil, err
}
colorProfile := md.???()
linearisedImg := image.NewRGBA64(img.Bounds())
switch colorProfile {
case adobeRGB:
adobergb.LineariseImage(linearisedImg, img, runtime.NumCPU())
case displayP3:
displayP3.LineariseImage(linearisedImg, img, runtime.NumCPU())
...
}
Is there a way I can get such a value? Thanks!
Hi! I'm trying out your library for my image processing web server and seeing a strange bug when trying to get the description of the color space for some JPG images with a Display P3 color profile. I have attached one such image:
When I try to decode the description, I get the error "expected 'desc' but got 'desc'" even though the macOS preview window correctly shows the color space as Display P3.
Formats like TIFF, PDF, and others can contain multiple images. One way to handle this would be to return [](*meta.Data)
from the Load() for such containers, and add an imagePath
field and an ImagePage()
method to meta.Data
indicating which image from the file the metadata describes.
The image path probably needs to be a string. For many formats this will simply hold the string representation of an integer index, but for a format like PDF a more general approach to paths is needed. It is useful if the path is human readable for debugging purposes, but the content of the path only needs to be meaningful to the image file decoder.
While I am thinking about it, it may also be useful to add isEmbedded
to the either the ICC header or to meta.Data
to day where the ICC profile came from. In formats like PDF, the ICC profile embedded in the image can be overridden by a separately stored profile that is associated with the image. It can be helpful to know which kind you are dealing with.
Since the two profiles may not be the same (e.g. when the embedded profile has been intentionally overridden in a PDF), we may want meta.Data
to distinguish between the active ICC profile and the embedded ICC profile. My suggestion would be that the current iccProfileX
fields hold the active (working) profile so that current behavior is not altered, and that embeddedProfileX
fields be added. Usually these will reference the same data.
It's not clear from the documentation how to linearise an image in an unknown color space.
Given that I have gotten the ICCProfile struct from the metadata. How do I go from that to a linearisation? The equivalent code using lcms would be to use cmcCreateTransform with the input profile read from the image and whatever output profile you want.
Apologies if I am missing something obvious.
Hi @mandykoh! Thanks again for your help with the Display P3 profiles.
I've got the profile detection working now, but the new issue is that the built in Go image encoding for jpeg / png images doesn't embed ICC profiles or have a way to do this as far as I can tell.
For conversions from Display P3 -> sRGB I suppose this is okay since images without an ICC profile are generally understood to be in the sRGB color space. That said, it would be nice to be able to write images with sRGB, Display P3, Adobe RGB or ProPhoto color profiles after using your library to linearize and convert between color profiles.
I understand it would be a lot of work to add full support for this, but it would be nice to at least be able to tag images with an existing profile once I write them / during the encoding process.
This repository has Creative Commons licensed compact ICC profiles we could use:
https://github.com/saucecontrol/Compact-ICC-Profiles
Do you know how much work it would be to add support for at least attaching these profiles to images?
And if you're too busy to work on this, I'd be happy to take a crack at it if you could give me a few pointers.
In autometa.Load I believe this:
return nil, imgStream, fmt.Errorf("unrecognised image format")
should be:
return nil, inputStream, fmt.Errorf("unrecognised image format")
to get back the buffered data in the stream.
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.