2023年4月23日 星期日

Batch-Image-Converter

batch_img_convert

batch_img_convert

This is a Windows x64 program written in Delphi 11.4 that can batch convert image files of different formats such as BMP, JPG, PNG, GIF, TIFF.

Features

  • You can select single files or folders to convert
  • You can recursively convert all image files in the folder
  • You can choose the output image format and quality
  • You can choose whether to overwrite the original file or save as a new file
  • You can view the progress and result of the conversion

How to use

  1. Download and unzip all files in the Win64/Release folder
  2. Run the batch_img_convert.exe program
  3. Click the "Add Files" button and select the image files or folders you want to convert
  4. Click the "Convert" button and select the output image format and quality
  5. Click the "Start" button to start converting image files
  6. Wait for the conversion to complete and check the conversion result

2023年4月12日 星期三

XYZ 轉色溫的方式

function XYZToColorTemperature(X, Y, Z: Double): Double;
var
  n, u, v, duv: Double;
begin
  // Normalize XYZ values
  n := X + Y + Z;
  if (n = 0) then
    Exit(0);
  X := X / n;
  Y := Y / n;
  Z := Z / n;

  // Calculate u and v values
  u := (4 * X) / (-2 * X + 12 * Y + 3);
  v := (9 * Y) / (-2 * X + 12 * Y + 3);

  // Calculate duv (distance from Planckian locus)
  duv := 0;
  if (u - 0.20917 * v) > 0.46228 then
    duv := (u - 0.20917 * v - 0.46228) / 0.02
  else if ((0.08067 * v - u) > 0.17697) then
    duv := (0.08067 * v - u - 0.17697) / 0.02;

  // Calculate color temperature
  Result := (1.0 / ((-4.607 * duv + 2.9672) * 1e-3) + 1.0 / 500) * 1e3;
end;

2023年4月11日 星期二

RGB to XYZ code example by delphi

procedure XYZToLab(X, Y, Z: Double; out L, a, b: Double);

const

  Xn = 95.047;

  Yn = 100.000;

  Zn = 108.883;

var

  fx, fy, fz: Double;

begin

  // calculate the relative luminance

  fy := Power(Y/Yn, 1/3);

  if Y/Yn <= 0.008856 then

    fy := 7.787 * Y/Yn + 16/116;


  // calculate a and b

  fx := Power(X/Xn, 1/3);

  if X/Xn <= 0.008856 then

    fx := 7.787 * X/Xn + 16/116;


  fz := Power(Z/Zn, 1/3);

  if Z/Zn <= 0.008856 then

    fz := 7.787 * Z/Zn + 16/116;


  L := 116 * fy - 16;

  a := 500 * (fx - fy);

  b := 200 * (fy - fz);

end;





 var

  X, Y, Z, L, a, b: Double;

begin

  // set the XYZ color values

  X := 45.242;

  Y := 52.876;

  Z := 73.215;


  // convert the XYZ color to CIELAB

  XYZToLab(X, Y, Z, L, a, b);


  // output the CIELAB color values

  ShowMessage(Format('L* = %f, a* = %f, b* = %f', [L, a, b]));

end;


色彩空間的 轉換 XYZ to Lab

 procedure XYZToLab(X, Y, Z: Double; out L, a, b: Double);

const

  Xn = 95.047;

  Yn = 100.000;

  Zn = 108.883;

var

  fx, fy, fz: Double;

begin

  // calculate the relative luminance

  fy := Power(Y/Yn, 1/3);

  if Y/Yn <= 0.008856 then

    fy := 7.787 * Y/Yn + 16/116;


  // calculate a and b

  fx := Power(X/Xn, 1/3);

  if X/Xn <= 0.008856 then

    fx := 7.787 * X/Xn + 16/116;


  fz := Power(Z/Zn, 1/3);

  if Z/Zn <= 0.008856 then

    fz := 7.787 * Z/Zn + 16/116;


  L := 116 * fy - 16;

  a := 500 * (fx - fy);

  b := 200 * (fy - fz);

end;



call:

var X, Y, Z, L, a, b: Double; begin // set the XYZ color values X := 45.242; Y := 52.876; Z := 73.215; // convert the XYZ color to CIELAB XYZToLab(X, Y, Z, L, a, b); // output the CIELAB color values ShowMessage(Format('L* = %f, a* = %f, b* = %f', [L, a, b])); end;