Do not reopen stdout while image resizing #7

Merged
tastytea merged 1 commits from mymedia2/libravatarserv:patch-1 into master 2020-10-24 08:41:14 +02:00
Contributor

On Linux, some web-servers (Apache in particular) close file with fd = 1 and offer something else as stdout. Notable difference can be seen with a pipe and an immediate redirection. Consider:

$ REQUEST_URI=/avatar/68b329da9893e34099c7d8ad5cb9c940 libravatarserv | cat > /tmp/response1.out
$ REQUEST_URI=/avatar/68b329da9893e34099c7d8ad5cb9c940 libravatarserv > /tmp/response2.out
$ diff -s /tmp/response{1,2}.out
Binary files /tmp/response1.out and /tmp/response2.out differ

Solution.

The output should be identical in both cases. So do not let ImageMagick to open /dev/stdout by itself, instead write the resulted image to an in-memory buffer and then to a file associated with the "cout" global object.

Fixes: #6

On Linux, some web-servers (Apache in particular) close file with fd = 1 and offer something else as stdout. Notable difference can be seen with a pipe and an immediate redirection. Consider: $ REQUEST_URI=/avatar/68b329da9893e34099c7d8ad5cb9c940 libravatarserv | cat > /tmp/response1.out $ REQUEST_URI=/avatar/68b329da9893e34099c7d8ad5cb9c940 libravatarserv > /tmp/response2.out $ diff -s /tmp/response{1,2}.out Binary files /tmp/response1.out and /tmp/response2.out differ Solution. The output should be identical in both cases. So do not let ImageMagick to open /dev/stdout by itself, instead write the resulted image to an in-memory buffer and then to a file associated with the "cout" global object. Fixes: #6
tastytea merged commit 53466aadef into master 2020-10-24 08:41:14 +02:00
Owner

Thanks!

Thanks!
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: tastytea/libravatarserv#7
No description provided.