# PIKA - Photo and Image Kooker Application # Copyright (C) 1995 Spencer Kimball and Peter Mattis # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # "Perlized" from C source by Manish Singh sub image_get_color_profile { $blurb = "Returns the image's color profile"; $help = <<'HELP'; This procedure returns the image's color profile, or NULL if the image has no color profile assigned. HELP &mitch_pdb_misc('2015', '2.10'); $lib_private = 1; @inargs = ( { name => 'image', type => 'image', desc => 'The image' } ); @outargs = ( { name => 'profile_data', type => 'bytes', desc => "The image's serialized color profile." } ); %invoke = ( code => <<'CODE' { PikaColorProfile *profile; profile = pika_image_get_color_profile (image); if (profile) { const guint8 *data; gsize length; data = pika_color_profile_get_icc_profile (profile, &length); profile_data = g_bytes_new (data, length); } } CODE ); } sub image_get_effective_color_profile { $blurb = "Returns the color profile that is used for the image"; $help = <<'HELP'; This procedure returns the color profile that is actually used for this image, which is the profile returned by pika_image_get_color_profile() if the image has a profile assigned, or a generated default RGB or grayscale profile, according to the image's type. HELP &mitch_pdb_misc('2015', '2.10'); $lib_private = 1; @inargs = ( { name => 'image', type => 'image', desc => 'The image' } ); @outargs = ( { name => 'profile_data', type => 'bytes', desc => "The image's serialized color profile." } ); %invoke = ( code => <<'CODE' { PikaColorProfile *profile; profile = pika_color_managed_get_color_profile (PIKA_COLOR_MANAGED (image)); if (profile) { const guint8 *data; gsize length; data = pika_color_profile_get_icc_profile (profile, &length); profile_data = g_bytes_new (data, length); } } CODE ); } sub image_set_color_profile { $blurb = "Sets the image's color profile"; $help = <<'HELP'; This procedure sets the image's color profile, or unsets it if NULL is passed as 'color_profile'. This procedure does no color conversion. However, it will change the pixel format of all layers to contain the babl space matching the profile. You must call this procedure before adding layers to the image. HELP &mitch_pdb_misc('2015', '2.10'); $lib_private = 1; @inargs = ( { name => 'image', type => 'image', desc => 'The image' }, { name => 'color_profile', type => 'bytes', desc => 'The new serialized color profile' } ); %invoke = ( code => <<'CODE' { if (color_profile) { PikaColorProfile *profile; profile = pika_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL), g_bytes_get_size (color_profile), error); if (profile) { success = pika_image_assign_color_profile (image, profile, progress, error); g_object_unref (profile); } else success = FALSE; } else { success = pika_image_assign_color_profile (image, NULL, progress, error); } } CODE ); } sub image_set_color_profile_from_file { $blurb = "Sets the image's color profile from an ICC file"; $help = <<'HELP'; This procedure sets the image's color profile from a file containing an ICC profile, or unsets it if NULL is passed as 'file'. This procedure does no color conversion. However, it will change the pixel format of all layers to contain the babl space matching the profile. You must call this procedure before adding layers to the image. HELP &mitch_pdb_misc('2015', '2.10'); @inargs = ( { name => 'image', type => 'image', desc => 'The image' }, { name => 'file', type => 'file', desc => 'The file containing the new color profile' } ); %invoke = ( code => <<'CODE' { if (file) { PikaColorProfile *profile; profile = pika_color_profile_new_from_file (file, error); if (profile) { success = pika_image_assign_color_profile (image, profile, progress, error); g_object_unref (profile); } else success = FALSE; } else { success = pika_image_assign_color_profile (image, NULL, progress, error); } } CODE ); } sub image_get_simulation_profile { $blurb = "Returns the image's simulation color profile"; $help = <<'HELP'; This procedure returns the image's simulation color profile, or NULL if the image has no simulation color profile assigned. HELP &alxsa_pdb_misc('2022', '3.0'); $lib_private = 1; @inargs = ( { name => 'image', type => 'image', desc => 'The image' } ); @outargs = ( { name => 'profile_data', type => 'bytes', desc => "The image's serialized simulation color profile." } ); %invoke = ( code => <<'CODE' { PikaColorProfile *profile; profile = pika_image_get_simulation_profile (image); if (profile) { const guint8 *data; gsize length; data = pika_color_profile_get_icc_profile (profile, &length); profile_data = g_bytes_new (data, length); } } CODE ); } sub image_set_simulation_profile { $blurb = "Sets the image's simulation color profile"; $help = <<'HELP'; This procedure sets the image's simulation color profile, or unsets it if NULL is passed as 'color_profile'. This procedure does no color conversion. HELP &alxsa_pdb_misc('2022', '3.0'); $lib_private = 1; @inargs = ( { name => 'image', type => 'image', desc => 'The image' }, { name => 'color_profile', type => 'bytes', desc => 'The new serialized simulation color profile'} ); %invoke = ( code => <<'CODE' { if (color_profile) { PikaColorProfile *profile; profile = pika_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL), g_bytes_get_size (color_profile), error); if (profile) { pika_image_set_simulation_profile (image, profile); g_object_unref (profile); } else { success = FALSE; } } else { pika_image_set_simulation_profile (image, NULL); } } CODE ); } sub image_set_simulation_profile_from_file { $blurb = "Sets the image's simulation color profile from an ICC file"; $help = <<'HELP'; This procedure sets the image's simulation color profile from a file containing an ICC profile, or unsets it if NULL is passed as 'file'. This procedure does no color conversion. HELP &alxsa_pdb_misc('2022', '3.0'); @inargs = ( { name => 'image', type => 'image', desc => 'The image' }, { name => 'file', type => 'file', desc => 'The file containing the new simulation color profile' } ); %invoke = ( code => <<'CODE' { if (file) { PikaColorProfile *profile; profile = pika_color_profile_new_from_file (file, error); if (profile) { pika_image_set_simulation_profile (image, profile); g_object_unref (profile); } else { success = FALSE; } } else { pika_image_set_simulation_profile (image, NULL); } } CODE ); } sub image_get_simulation_intent { $blurb = "Returns the image's simulation rendering intent"; $help = <<'HELP'; This procedure returns the image's simulation rendering intent. HELP &alxsa_pdb_misc('2022', '3.0'); @inargs = ( { name => 'image', type => 'image', desc => 'The image' } ); @outargs = ( { name => 'intent', type => 'enum PikaColorRenderingIntent', desc => "The image's simulation rendering intent." } ); %invoke = ( code => <<'CODE' { intent = pika_image_get_simulation_intent (image); } CODE ); } sub image_set_simulation_intent { $blurb = "Sets the image's simulation rendering intent"; $help = <<'HELP'; This procedure sets the image's simulation rendering intent. HELP &alxsa_pdb_misc('2022', '3.0'); @inargs = ( { name => 'image', type => 'image', desc => 'The image' }, { name => 'intent', type => 'enum PikaColorRenderingIntent', desc => 'A PikaColorRenderingIntent' } ); %invoke = ( code => <<'CODE' { pika_image_set_simulation_intent (image, intent); } CODE ); } sub image_get_simulation_bpc { $blurb = "Returns whether the image has Black Point Compensation enabled for its simulation"; $help = <<'HELP'; This procedure returns whether the image has Black Point Compensation enabled for its simulation HELP &alxsa_pdb_misc('2022', '3.0'); @inargs = ( { name => 'image', type => 'image', desc => 'The image' } ); @outargs = ( { name => 'bpc', type => 'boolean', desc => "The Black Point Compensation status." } ); %invoke = ( code => <<'CODE' { bpc = pika_image_get_simulation_bpc (image); } CODE ); } sub image_set_simulation_bpc { $blurb = "Sets whether the image has Black Point Compensation enabled for its simulation"; $help = <<'HELP'; This procedure whether the image has Black Point Compensation enabled for its simulation HELP &alxsa_pdb_misc('2022', '3.0'); @inargs = ( { name => 'image', type => 'image', desc => 'The image' }, { name => 'bpc', type => 'boolean', desc => 'The Black Point Compensation status.' } ); %invoke = ( code => <<'CODE' { pika_image_set_simulation_bpc (image, bpc); } CODE ); } sub image_convert_color_profile { $blurb = "Convert the image's layers to a color profile"; $help = <<'HELP'; This procedure converts from the image's color profile (or the default RGB or grayscale profile if none is set) to the given color profile. Only RGB and grayscale color profiles are accepted, according to the image's type. HELP &mitch_pdb_misc('2015', '2.10'); $lib_private = 1; @inargs = ( { name => 'image', type => 'image', desc => 'The image' }, { name => 'color_profile', type => 'bytes', desc => 'The serialized color profile' }, { name => 'intent', type => 'enum PikaColorRenderingIntent', desc => 'Rendering intent' }, { name => 'bpc', type => 'boolean', desc => 'Black point compensation' } ); %invoke = ( code => <<'CODE' { if (color_profile) { PikaColorProfile *profile; profile = pika_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL), g_bytes_get_size (color_profile), error); if (profile) { success = pika_image_convert_color_profile (image, profile, intent, bpc, progress, error); g_object_unref (profile); } else success = FALSE; } else success = FALSE; } CODE ); } sub image_convert_color_profile_from_file { $blurb = "Convert the image's layers to a color profile"; $help = <<'HELP'; This procedure converts from the image's color profile (or the default RGB or grayscale profile if none is set) to an ICC profile specified by 'file'. Only RGB and grayscale color profiles are accepted, according to the image's type. HELP &mitch_pdb_misc('2015', '2.10'); @inargs = ( { name => 'image', type => 'image', desc => 'The image' }, { name => 'file', type => 'file', desc => 'The file containing the new color profile' }, { name => 'intent', type => 'enum PikaColorRenderingIntent', desc => 'Rendering intent' }, { name => 'bpc', type => 'boolean', desc => 'Black point compensation' } ); %invoke = ( code => <<'CODE' { if (file) { PikaColorProfile *profile; profile = pika_color_profile_new_from_file (file, error); if (profile) { success = pika_image_convert_color_profile (image, profile, intent, bpc, progress, error); g_object_unref (profile); } else success = FALSE; } else success = FALSE; } CODE ); } @headers = qw( "libpikacolor/pikacolor.h" "core/pikaimage-color-profile.h" "pika-intl.h"); @procs = qw(image_get_color_profile image_get_effective_color_profile image_set_color_profile image_set_color_profile_from_file image_get_simulation_profile image_set_simulation_profile image_set_simulation_profile_from_file image_get_simulation_intent image_set_simulation_intent image_get_simulation_bpc image_set_simulation_bpc image_convert_color_profile image_convert_color_profile_from_file); %exports = (app => [@procs], lib => [@procs]); $desc = 'Image Color Profile'; $doc_title = 'pikaimagecolorprofile'; $doc_short_desc = 'Operations on an image\'s color profile.'; $doc_long_desc = 'Operations on an image\'s color profile.'; 1;