| @@ -205,18 +205,21 @@ sub get_page_image { | |||
| $size = $qs->{maxWidth}; | |||
| } | |||
| if ( !defined $id ) { | |||
| return gen_error_img($wh, $size, "No page found"); | |||
| } | |||
| my $original = sprintf("%s/%s/%s.jpeg", | |||
| $conf->{path}{global}, $conf->{path}{original}, $id); | |||
| 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 ) { | |||
| $cache_file = sprintf("%s/%s/%s-%s-%s.jpeg", | |||
| $conf->{path}{global}, $conf->{path}{images}, $id, $wh, $size); | |||
| } | |||
| gen_thumbnail($original, $cache_file, $wh, $size) if !-r $cache_file; | |||
| my $img=''; | |||
| @@ -231,7 +234,7 @@ sub get_page_image { | |||
| $img = gen_error_img($wh, $size, "No Image"); | |||
| } | |||
| return (200, "image/jpeg", $img); | |||
| return $img; | |||
| } | |||
| sub gen_thumbnail { | |||
| @@ -280,16 +283,26 @@ sub api_v1_POST_documents { | |||
| } | |||
| 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 { | |||
| 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 { | |||
| 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 | |||