Skip to content

Commit

Permalink
maintain aspect ratio of only one of x or y are given
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.kfish.org/fastphoto/trunk@104 9c49b5d1-7df3-0310-bce2-b7278e68f44c
  • Loading branch information
conrad committed Feb 4, 2006
1 parent 96eac3c commit 5c2f113
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/cgi.c
Expand Up @@ -73,8 +73,8 @@ cgi_init (fastphoto_t * params)

params->infile = path_translated;
params->outfile = "/tmp/cache.jpg";
params->x = FASTPHOTO_DEFAULT_X;
params->y = FASTPHOTO_DEFAULT_Y;
params->x = 0;
params->y = 0;

parse_query (params, query_string);

Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Expand Up @@ -34,8 +34,8 @@ main (int argc, char * argv[])

params.infile = argv[1];
params.outfile = argv[2];
params.x = 128;
params.y = 128;
params.x = 0;
params.y = 0;
}

resize (&params);
Expand Down
16 changes: 14 additions & 2 deletions src/resize.c
Expand Up @@ -6,13 +6,25 @@ void
resize (fastphoto_t * params)
{
Epeg_Image *im;
int x, y;
int x, y, w, h;

im = epeg_file_open(params->infile);

epeg_size_get (im, &w, &h);

x = params->x;
y = params->y;

im = epeg_file_open(params->infile);
if (x == 0 && y == 0) {
x = w;
y = h;
} else if (x == 0) {
x = w*y/h;
} else if (y == 0) {
y = h*x/w;
}
epeg_decode_size_set(im, x, y);

epeg_file_output_set(im, params->outfile);
epeg_encode(im);
epeg_close(im);
Expand Down

0 comments on commit 5c2f113

Please sign in to comment.