librelist archives

« back to archive

Coverting RGB image to CYMK usiing 'profile' option

Coverting RGB image to CYMK usiing 'profile' option

From:
Kaviraj Kanagaraj
Date:
2015-07-06 @ 13:45
Hi Everyone,

I need convert an RGB image to CYMK image using profile option. To be
precise

How to do the following command using wand library?
"convert rgb.jpg -profile USWebCoatedSWOP.icc cymk.jpg"


Please help me trying figure it out.

Thanks in advance

Re: [wand] Coverting RGB image to CYMK usiing 'profile' option

From:
Eric McConville
Date:
2015-07-06 @ 14:09
The profile methods have yet to be implemented; specifically, 
MagickProfileImage 
<http://www.imagemagick.org/api/magick-property.php#MagickProfileImage> & 
MagickSetImageProfile 
<http://www.imagemagick.org/api/magick-property.php#MagickSetImageProfile>.
Wand does supply everything you need to implement this yourself, but 
you’ll need to be creative on how you apply any such implementation.

Below is an example solution. Note: This is untested & ignores error 
handling, but should get you started.

import ctypes
from wand.api import library
from wand.image import Image

# Register C-API methods
library.MagickProfileImage.argtypes = [ctypes.c_void_p,  # wand
                                       ctypes.c_char_p,  # name
                                       ctypes.c_char_p,  # profile
                                       ctypes.c_size_t]  # profile length

# Extend existing wand.image.Image class
class MyImage(Image):
    def profile_import(self, filepath):
        """Read contents of a file, and set as ICC profile"""
        with open(filepath, 'r') as profile_blob:
            library.MagickProfileImage(self.wand,
                                       'ICC',
                                       profile_blob,
                                       len(profile_blob))




> On Jul 6, 2015, at 8:45 AM, Kaviraj Kanagaraj <kaviraj@launchyard.com> wrote:
> 
> Hi Everyone,
> 
> I need convert an RGB image to CYMK image using profile option. To be precise
> 
> How to do the following command using wand library?
> "convert rgb.jpg -profile USWebCoatedSWOP.icc cymk.jpg"
> 
> 
> Please help me trying figure it out.
> 
> Thanks in advance

Re: [wand] Coverting RGB image to CYMK usiing 'profile' option

From:
Kaviraj Kanagaraj
Date:
2015-07-07 @ 08:16
Thanks Eric. I will try to implement by extending Image class. Thanks again
for your info.

On Mon, Jul 6, 2015 at 7:39 PM, Eric McConville <emcconville@emcconville.com
> wrote:

> The profile methods have yet to be implemented; specifically,
> MagickProfileImage
> <http://www.imagemagick.org/api/magick-property.php#MagickProfileImage> &
> MagickSetImageProfile
> <http://www.imagemagick.org/api/magick-property.php#MagickSetImageProfile>
> .
> Wand does supply everything you need to implement this yourself, but
> you’ll need to be creative on how you apply any such implementation.
>
> Below is an example solution. Note: This is untested & ignores error
> handling, but should get you started.
>
> import ctypes
> from wand.api import library
> from wand.image import Image
>
> # Register C-API methods
> library.MagickProfileImage.argtypes = [ctypes.c_void_p,  # wand
>                                        ctypes.c_char_p,  # name
>                                        ctypes.c_char_p,  # profile
>                                        ctypes.c_size_t]  # profile length
>
> # Extend existing wand.image.Image class
> class MyImage(Image):
>     def profile_import(self, filepath):
>         """Read contents of a file, and set as ICC profile"""
>         with open(filepath, 'r') as profile_blob:
>             library.MagickProfileImage(self.wand,
>                                        'ICC',
>                                        profile_blob,
>                                        len(profile_blob))
>
>
>
>
>
> On Jul 6, 2015, at 8:45 AM, Kaviraj Kanagaraj <kaviraj@launchyard.com>
> wrote:
>
> Hi Everyone,
>
> I need convert an RGB image to CYMK image using profile option. To be
> precise
>
> How to do the following command using wand library?
> "convert rgb.jpg -profile USW ebCoatedSWOP.icc cymk.jpg"
>
>
> Please help me trying figure it out.
>
> Thanks in advance
>
>
>