#!/usr/bin/perl
use strict;
use warnings;
use Image::Imlib2;
use feature "say";
#can read directory and make an array of images, @files
my ($image);
#my $file1=("./thur_with_gel.png"); 
my $file1=("./_MG_7784.png");

#for (my $i=0;$i<=$#files;$i++){
#$file=$files[0];
say $file1;
make_green($file1);
$image->save("cloned-Wood_on_white.png");

#my $clone=$image->clone;
#$clone->has_alpha(1);
#$clone->save("cloned-Wood_on_white.png");
say "done";
exit;


sub make_green{
my $file=$_[0];
say $file;
$image=Image::Imlib2->load($file);
$image->has_alpha(1);
$image->will_blend(0);
$image->set_colour(0,0,0,0); 
my $width = $image->width;
my $height = $image->height;
for my $y (0 .. $height - 1) {
	
   for my $x (0 .. $width - 1) {
     my  ($red, $green, $blue, $alpha) = $image->query_pixel($x, $y);
     #say "$red, $green, $blue, $alpha";
     #if($green>200 && $red<50 ||$green>200 && $blue<100 ||$green>235  ){ 
 #    if($green>100 && $red<$green){
  if($green>100&&$red<40){      
         $image->draw_point($x, $y);
           }
 #          if($green>100 && $red==0){ 
#		$image->draw_point($x, $y);	   
#    }
    }
  }	
return;	
	}




