Comments (13)
Continuation...
So I reply to Richard directly (accidentally off-list) with
Yes please :)
So Richard replies
I can do an example that does a colorspace conversion.
Yes please :)
So I had a try at this just now, but my python knowledge is lacking.
I'm not sure how you get access to the raw bytes in an image from
python and what coding conventions you'd use in a library. Ideas
welcome here. I've included the incomplete code below. I'm happy to
add more functionality into libcolord if this is required (e.g. if we
want to pass an array of "ddd" to the process function).Richard
import gi
gi.require_version('Colord', '1.0')
from gi.repository import Colord
from gi.repository import Gio
# load sRGB (without using the daemon)
icc_src = Colord.Icc.new()
h = Gio.file_new_for_path('/usr/share/color/icc/colord/sRGB.icc')
icc_src.load_file(h, Colord.IccLoadFlags.NONE)
# load AdobeRGB (without using the daemon)
icc_dst = Colord.Icc.new()
h = Gio.file_new_for_path('/usr/share/color/icc/colord/AdobeRGB1998.icc')
icc_dst.load_file(h, Colord.IccLoadFlags.NONE)
# set up the transform
transform = Colord.Transform.new()
transform.set_input_pixel_format(Colord.PIXEL_FORMAT_RGB24)
transform.set_input_icc(icc_src)
transform.set_output_icc(icc_dst)
transform.set_output_pixel_format(Colord.PIXEL_FORMAT_RGB24)
transform.set_rendering_intent(Colord.RenderingIntent.PERCEPTUAL)
transform.set_bpc(True)
# hmm, not sure how to make process() accept raw image data
data_in = [0.5,0.6,0.7]
transform.process(data_in, data_in, 1, 1, 1, None)
from swatchbooker.
Above Richard writes:
So I had a try at this just now, but my python knowledge is lacking.
I'm not sure how you get access to the raw bytes in an image from
python and what coding conventions you'd use in a library. Ideas
welcome here. I've included the incomplete code below. I'm happy to
add more functionality into libcolord if this is required (e.g. if we
want to pass an array of "ddd" to the process function).
So I'm CCing some possible help from friends:
@berteh
@sk1project
@aoloe
@QuLogic
from swatchbooker.
According to this, functions with bare gpointer
should not be exposed over introspection. They should instead be annotated with the expected array dimensions. However, this seems a bit difficult since the function accepts an array in multiple dimensions with varied data types.
You can create the memory pointer using NumPy arrays. I'm not sure why the example uses [0.5, 0.6, 0.7]
; the settings are PIXEL_FORMAT_RGB24
which should be 3 bytes of 0-255, not floats.
This works but since you are passing around pointers and stuff, you should check the caveats and ensure your array is allocated suitably:
data_in = np.array([0.5*255, 0.6*255, 0.7*255],
dtype=np.uint8) # NOTE: Use correct type here, not floats!
print(data_in)
transform.process(data_in.ctypes.data, data_in.ctypes.data, 1, 1, 1, None)
print(data_in)
and outputs:
[127 153 178]
[134 152 176]
from swatchbooker.
There's now some bindings for Python3: https://bitbucket.org/johnpfjefferies/little-cms-python-bindings/
No idea what it would take to convert it to python 2...
from swatchbooker.
from swatchbooker.
True but since I have no clue about C programming or Python packaging, I have no idea how to use it with SwatchBooker.
PIL/Pillow also has lcms2 bindings but only with a limited set of features that don't match the few ones I need...
from swatchbooker.
from swatchbooker.
the functions I'm using in SwatchBooker are:
cmsOpenProfileFromFile
cmsCreate_sRGBProfile
cmsCreateLab4Profile
cmsCreateXYZProfile
cmsCreateTransform
cmsCloseProfile
cmsDoTransform
cmsDeleteTransform
from swatchbooker.
from swatchbooker.
PIL bitmaps are converted directly inside PIL but their binding don't expose the "simple" color transform functions...
In the meantime I did manage to have it working with an updated version of ctypesgen and the THR version of the functions so there's no emergency anymore.
Thank you anyway!
from swatchbooker.
Just released 0.7.5 with the lcms2 bindings.
from swatchbooker.
from swatchbooker.
from swatchbooker.
Related Issues (15)
- Downstream fix for installing Swatchbooker via Homebrew HOT 2
- Write Adobe aco (*.ACO)
- Traceback when starting swatchbooker HOT 1
- metainfo for swatchbooker needed on Gnome Software
- Windows .exe binaries
- Broken Windows download link
- Update website
- Switch to python 3 HOT 6
- Migrating from Launchpad to Github HOT 2
- please make a 0.7.4 release HOT 3
- Swatchbooker description and website HOT 4
- Homebrew formula for Swatchbooker
- Windows installer?
- Improve color management performance
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swatchbooker.