| $size = $qs->{maxWidth}; | $size = $qs->{maxWidth}; | ||||
| } | } | ||||
| if ( !defined $id ) { | |||||
| return gen_error_img($wh, $size, "No page found"); | |||||
| } | |||||
| my $original = sprintf("%s/%s/%s.jpeg", | my $original = sprintf("%s/%s/%s.jpeg", | ||||
| $conf->{path}{global}, $conf->{path}{original}, $id); | $conf->{path}{global}, $conf->{path}{original}, $id); | ||||
| my $cache_file = sprintf("%s/%s/%s-original.jpeg", | my $cache_file = sprintf("%s/%s/%s-original.jpeg", | ||||
| $conf->{path}{global}, $conf->{path}{images}, $id); | |||||
| $conf->{path}{global}, $conf->{path}{images}, $id); | |||||
| if ( defined $wh && defined $size ) { | if ( defined $wh && defined $size ) { | ||||
| $cache_file = sprintf("%s/%s/%s-%s-%s.jpeg", | $cache_file = sprintf("%s/%s/%s-%s-%s.jpeg", | ||||
| $conf->{path}{global}, $conf->{path}{images}, $id, $wh, $size); | $conf->{path}{global}, $conf->{path}{images}, $id, $wh, $size); | ||||
| } | } | ||||
| gen_thumbnail($original, $cache_file, $wh, $size) if !-r $cache_file; | gen_thumbnail($original, $cache_file, $wh, $size) if !-r $cache_file; | ||||
| my $img=''; | my $img=''; | ||||
| $img = gen_error_img($wh, $size, "No Image"); | $img = gen_error_img($wh, $size, "No Image"); | ||||
| } | } | ||||
| return (200, "image/jpeg", $img); | |||||
| return $img; | |||||
| } | } | ||||
| sub gen_thumbnail { | sub gen_thumbnail { | ||||
| } | } | ||||
| sub api_v1_POST_documents_id_data { return api_error(501,"Not yet implemented"); } | sub api_v1_POST_documents_id_data { return api_error(501,"Not yet implemented"); } | ||||
| # get document image/thumbnail | |||||
| sub api_v1_GET_documents_id_image { | sub api_v1_GET_documents_id_image { | ||||
| my($id, $qs, $post, $user) = @_; | |||||
| my($id, $qs, $post, $user) = @_; | |||||
| my $pageid; | |||||
| return api_error(501,"Not yet implemented"); | |||||
| my $q = sqlquery($dbh, "SELECT id FROM pages WHERE documentId = ? ORDER BY id DESC LIMIT 1", $id); | |||||
| while(my($myid)=$q->fetchrow_array()) { | |||||
| $pageid = $myid; | |||||
| } | |||||
| return api_v1_GET_documents_id_image($pageid, $qs, $post, $user); | |||||
| } | } | ||||
| # get page image/thumbnail | |||||
| sub api_v1_GET_pages_image { | sub api_v1_GET_pages_image { | ||||
| my($id, $qs, $post, $user) = @_; | my($id, $qs, $post, $user) = @_; | ||||
| get_page_image($id, $qs); | |||||
| return api_error(501,"Not yet implemented"); | |||||
| return (200, "image/jpeg", get_page_image($id, $qs)); | |||||
| } | } | ||||
| # get a list of document objects | # get a list of document objects |