73
73
my $success = $exifTool->ExtractInfo( out_str( $artifact->full_filename ));
74
74
#my $info = $exifTool->GetInfo( { Group0 => ['File', 'EXIF', 'ExifIFD', 'XMP-exif'] } );
75
my $info = $exifTool->GetInfo(['FileType', 'ColorSpace', 'ImageWidth', 'ImageHeight'],
75
my $info = $exifTool->GetInfo(['FileType', 'ColorSpaceData', 'ImageWidth', 'ImageHeight'],
77
Group0 => ['File', 'ICC_Profile']});
78
78
#intercn(sprintf('groups=%s', Dumper([Image::ExifTool::GetAllGroups(0)])));
79
79
#intercn(sprintf('tags=%s', Dumper([$exifTool->GetFoundTags()])));
81
81
#intercn(Dumper([$exifTool->GetGroups()]));
82
82
#intercn(Dumper($info));
83
#intercn(sprintf('$info->{ColorSpaceData}=[%s]', $info->{ColorSpaceData}));
84
85
interc(sprintf(get_strres('Checking_Artifact_X_X'), $self->title, $artifact->title));
85
#intercn(sprintf('$info->{ColorSpace}=%s', $info->{ColorSpace}));
87
87
foreach my $row (@{$checks_rows}){
88
my $check_value = uc($row->{check_value});
88
my $check_value = $row->{check_value};
90
90
#intercn(Dumper($row));
91
91
#intercn(sprintf('$check_value=%s', $check_value));
101
if ( ($row->{check_type} eq 'colorspace')
102
and ($info->{ColorSpaceData} !~ /$check_value/)){
105
intercn(sprintf(get_strres('Check_Failed_X_X_X_X'), $row->{check_type},
106
$info->{ColorSpaceData}, ' equal', $row->{check_value}, $artifact->full_filename));
101
if ($row->{check_type} eq 'min_resolution'){
112
if(scalar(grep {$row->{check_type} eq $_} qw(min_resolution max_resolution))){
102
114
my $resolution = ceil($info->{ImageWidth} * $info->{ImageHeight} / 1024 /1024);
104
#intercn($resolution);
106
unless($resolution > $row->{check_value}){
108
intercn(sprintf(get_strres('Check_Failed_X_X_X_X'), $row->{check_type},
109
$resolution, get_strres('greater_than'), uc($row->{check_value}), $artifact->full_filename));
116
if ($row->{check_type} eq 'min_resolution'){
118
#intercn($resolution);
120
unless($resolution > $row->{check_value}){
122
intercn(sprintf(get_strres('Check_Failed_X_X_X_X'), $row->{check_type},
123
$resolution, get_strres('greater_than'), $row->{check_value}, $artifact->full_filename));
129
if ($row->{check_type} eq 'max_resolution'){
131
#intercn($resolution);
133
unless($resolution < $row->{check_value}){
135
intercn(sprintf(get_strres('Check_Failed_X_X_X_X'), $row->{check_type},
136
$resolution, get_strres('less_than'), $row->{check_value}, $artifact->full_filename));
173
if ($row->{check_type} eq 'max_title_chars'){
174
my $chars = length( $artifact->title );
176
#intercn(Dumper([@words]));
178
if( $chars > $row->{check_value}){
180
intercn(sprintf(get_strres('Check_Failed_X_X_X_X'), $row->{check_type},
181
$chars, get_strres('less_than'), $row->{check_value}, $artifact->title));
187
if(scalar(grep {$row->{check_type} eq $_} qw(max_keywords min_keywords))){
188
my $keywords = scalar(@{$artifact->keywords});
190
#intercn(Dumper([@words]));
192
if (($row->{check_type} eq 'min_keywords')
193
and ($keywords < $row->{check_value}) ){
195
intercn(sprintf(get_strres('Check_Failed_X_X_X_X'), $row->{check_type},
196
$keywords, get_strres('greater_than'), $row->{check_value}, $artifact->title));
201
if (($row->{check_type} eq 'max_keywords')
202
and ($keywords > $row->{check_value}) ){
204
intercn(sprintf(get_strres('Check_Failed_X_X_X_X'), $row->{check_type},
205
$keywords, get_strres('less_than'), $row->{check_value}, $artifact->title));
145
211
#scalar(grep {$row->{check_type} eq $_} qw(min_quality colorspace))
148
214
#intercn(Dumper());
150
if( scalar(grep {$row->{check_type} eq $_} qw(min_quality colorspace))){
216
if( scalar(grep {$row->{check_type} eq $_} qw(min_quality))){
151
217
if (can_load(modules => { 'Image::Magick' => undef})){
153
219
my $image=Image::Magick->new;
173
if ( ($row->{check_type} eq 'colorspace')){
175
my $colorspace = $image->Get('colorspace');
177
unless($colorspace =~ /$check_value/){
180
intercn(sprintf(get_strres('Check_Failed_X_X_X_X'), $row->{check_type},
181
$colorspace, ' equal', uc($row->{check_value}), $artifact->full_filename));
188
241
intercn('Image::Magick not found, check <'.$row->{check_type}.'> skipped.');
208
261
foreach my $artifact (@$artifacts){
209
262
#intercn(sprintf('Artifact=%s', $artifact->title));
211
266
my $checks_rows = PSH::DB::get_stock_checks_rows($self->id, 'Image');
213
268
if ((not @{$checks_rows}) or $self->checks_passed($artifact, $checks_rows)){
222
277
10 # Ready for upload
280
if ($artifact_id and PSH::DB::insert_artifact_actions($artifact_id, $action_id)){
281
#Add new artifact to current batch
283
$local_action_id = $action_id;
226
287
# It is artifact from this stock
230
291
#intercn(sprintf('$artifact_id=%s', $artifact_id));
233
and PSH::DB::insert_artifact_actions($artifact_id, $action_id)
234
and $self->send_artifact($artifact, $action_id, $artifact_id, $skip_upload)){
294
and $self->send_artifact($artifact, $local_action_id, $artifact_id, $skip_upload)){
236
push (@result, $artifact);
296
if($local_action_id){
297
#Exclude existed in stock pic from new batch
298
push (@result, $artifact);