package Memories::Photo;
-use Apache2::Upload;
+#use Apache2::Upload;
use File::Basename;
use File::Copy;
use Archive::Any;
use File::Path qw(rmtree);
use File::Find;
use File::MMagic;
+use Image::Size qw(imgsize);
use strict;
use Carp qw(cluck confess);
use base qw(Memories::DBI Maypole::Model::CDBI::Plain);
my ($self, $r, $filename, $offered_name) = @_;
my $mm = File::MMagic->new;
my $res = $mm->checktype_filename($filename);
- warn "$filename is a $res\n";
if ($res =~ m{/x-zip} or $offered_name =~ /t(ar\.)?gz$/i) {
return $self->upload_archive($r, $filename);
} elsif ($offered_name =~ /\.(raw|nef|dng|cr2)/i) {
my ($self, $r, $filename, $offered_name) = @_;
my $jpg = tmpnam().".jpg";
system("dcraw -c $filename | convert - $jpg");
- my $photo = $self->upload_jpeg($r, $jpg, $offered_name);
$filename =~ /\.(.*)$/;
my $format = $1;
- $photo->format($format);
# Put the file in place
+ my $photo = $self->upload_jpeg($r, $jpg, $offered_name);
+ $photo->format($format);
copy($filename,
Memories->config->{data_store}."/".$photo->id.".".$format);
return $photo;
warn "Couldn't copy photo to ".$photo->path("file").": $!";
$photo->delete(); die;
}
- my ($x, $y) = dim(image_info($photo->path));
+ my ($x, $y, undef) = imgsize($photo->path);
$photo->x($x); $photo->y($y);
# Rotate?
$photo->make_thumb;
my $tags = $r->{params}{tags}.join " ", map { qq{"$_"} } $photo->tags_exif;
$photo->add_tags($tags);
-warn "D";
$photo->add_to_imageseek_library;
Memories->zap_cache();
-warn "E";
-
# Add system tags here
my $tag = "date:".$photo->shot->ymd;
$photo->add_to_system_tags({tag => Memories::SystemTag->find_or_create({name =>$tag}) });
}
use Cache::MemoryCache;
-use Image::Info qw(dim image_info);
use Image::ExifTool;
my $cache = new Cache::MemoryCache( { 'namespace' => 'MemoriesInfo' });
my $resized = Memories->config->{sizes}->[$size];
if (!$resized) { cluck "Asked for crazy size $size"; return; }
if ($resized eq "full") { return $self->path("url") }
- warn "Looking for path ".$self->path(file => $resized);
$self->scale($resized)
unless -e $self->path( file => $resized );
return $self->path(url => $resized);
map { split /\s*,\s*/, $md{$_}}
grep {$md{$_} and $md{$_} =~/[^ 0:]/}
(qw(Keywords Subject City State Location Country Province-State),
- 'Transmission Reference', 'Intellectual Genre',
+ 'Intellectual Genre',
'Country-Primary Location Name'
);
return keys %tags;