{"action":"created","issue":{"url":"https://api.github.com/repos/jcupitt/libvips/issues/1020","repository_url":"https://api.github.com/repos/jcupitt/libvips","labels_url":"https://api.github.com/repos/jcupitt/libvips/issues/1020/labels{/name}","comments_url":"https://api.github.com/repos/jcupitt/libvips/issues/1020/comments","events_url":"https://api.github.com/repos/jcupitt/libvips/issues/1020/events","html_url":"https://github.com/jcupitt/libvips/issues/1020","id":336370310,"node_id":"MDU6SXNzdWUzMzYzNzAzMTA=","number":1020,"title":"Saving any large image (Jpeg/PNG) is very slow using C code","user":{"login":"adel-boutros","id":18596826,"node_id":"MDQ6VXNlcjE4NTk2ODI2","avatar_url":"https://avatars2.githubusercontent.com/u/18596826?v=4","gravatar_id":"","url":"https://api.github.com/users/adel-boutros","html_url":"https://github.com/adel-boutros","followers_url":"https://api.github.com/users/adel-boutros/followers","following_url":"https://api.github.com/users/adel-boutros/following{/other_user}","gists_url":"https://api.github.com/users/adel-boutros/gists{/gist_id}","starred_url":"https://api.github.com/users/adel-boutros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adel-boutros/subscriptions","organizations_url":"https://api.github.com/users/adel-boutros/orgs","repos_url":"https://api.github.com/users/adel-boutros/repos","events_url":"https://api.github.com/users/adel-boutros/events{/privacy}","received_events_url":"https://api.github.com/users/adel-boutros/received_events","type":"User","site_admin":false},"labels":[{"id":15569166,"node_id":"MDU6TGFiZWwxNTU2OTE2Ng==","url":"https://api.github.com/repos/jcupitt/libvips/labels/question","name":"question","color":"02e10c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-27T20:11:08Z","updated_at":"2018-06-28T08:23:03Z","closed_at":null,"author_association":"NONE","body":"Hello,\r\n\r\nWe are actually testing libvips C native library and noticed it is very slow when the image is at a certain size. Our test case is a Jpeg image of 2 MB.\r\nWe are able to load 6 000 images per second but only write 66 images per second.\r\n\r\nThe image can be found here: https://ibb.co/edDUFT\r\nVips 8.6.3\r\n\r\nCan you please help me?\r\n\r\n```\r\n#include <stdio.h>\r\n#include <stdlib.h>\r\n#include <vips/vips.h>\r\n#include <time.h>\r\n#include <sys/time.h>\r\n\r\nvoid loadImage(VipsImage* img) {\r\n    char *buffer_out;\r\n    size_t length_out;\r\n    vips_image_write_to_buffer(img, \".jpeg[Q=75]\", (void**) &buffer_out, &length_out, NULL);\r\n    //g_object_unref(img);\r\n    g_free(buffer_out);\r\n}\r\n\r\nchar* readInput() {\r\n    // Read file as byte array\r\n    FILE *fl = fopen(\"in_vips.jpeg\", \"r\");\r\n    fseek(fl, 0, SEEK_END);\r\n    long len = ftell(fl);\r\n    char *buf = malloc(len);\r\n    fseek(fl, 0, SEEK_SET);\r\n    fread(buf, 1, len, fl);\r\n    fclose(fl);\r\n    return buf;\r\n}\r\n\r\nlong readInputLength() {\r\n    // Read file as byte array\r\n    FILE *fl = fopen(\"in_vips.jpeg\", \"r\");\r\n    fseek(fl, 0, SEEK_END);\r\n    long len = ftell(fl);\r\n    fclose(fl);\r\n    return len;\r\n}\r\n\r\nvoid vipsBuffer(char* buf, long len)\r\n{\r\n    //vips_leak_set(1);\r\n    int j;\r\n\r\n    fprintf(stdout, \"Starting vips\\n\");\r\n    fflush(stdout);\r\n\r\n    fprintf(stdout, \"Running buffer...\\n\");\r\n    struct timeval start, end;\r\n    int nbImages = 100;\r\n    VipsImage* img = vips_image_new_from_buffer(buf, len, NULL, NULL);\r\n    gettimeofday(&start, NULL);\r\n    for (j = 0; j < nbImages; ++j) {\r\n        loadImage(img);\r\n    }\r\n    gettimeofday(&end, NULL);\r\n    free(buf);\r\n    fprintf(stdout, \"Done\\n\");\r\n    long y = ((end.tv_sec * 1000000 + end.tv_usec)\r\n                 \t\t  - (start.tv_sec * 1000000 + start.tv_usec));\r\n\r\n    printf(\"We can process %ld Images/s (%ld ms)\\n\", (1000000 * nbImages / y), (y / 1000));\r\n    fflush(stdout);\r\n}\r\n\r\nint main(int argc, char *argv[]) {\r\n    VIPS_INIT (argv[0]);\r\n    char* buf = readInput();\r\n    long len = readInputLength();\r\n    vipsBuffer(buf, len);\r\n    vips_shutdown();\r\n\r\n    return 0;\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/jcupitt/libvips/issues/comments/400953907","html_url":"https://github.com/jcupitt/libvips/issues/1020#issuecomment-400953907","issue_url":"https://api.github.com/repos/jcupitt/libvips/issues/1020","id":400953907,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDk1MzkwNw==","user":{"login":"jcupitt","id":580843,"node_id":"MDQ6VXNlcjU4MDg0Mw==","avatar_url":"https://avatars2.githubusercontent.com/u/580843?v=4","gravatar_id":"","url":"https://api.github.com/users/jcupitt","html_url":"https://github.com/jcupitt","followers_url":"https://api.github.com/users/jcupitt/followers","following_url":"https://api.github.com/users/jcupitt/following{/other_user}","gists_url":"https://api.github.com/users/jcupitt/gists{/gist_id}","starred_url":"https://api.github.com/users/jcupitt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcupitt/subscriptions","organizations_url":"https://api.github.com/users/jcupitt/orgs","repos_url":"https://api.github.com/users/jcupitt/repos","events_url":"https://api.github.com/users/jcupitt/events{/privacy}","received_events_url":"https://api.github.com/users/jcupitt/received_events","type":"User","site_admin":false},"created_at":"2018-06-28T08:23:03Z","updated_at":"2018-06-28T08:23:03Z","author_association":"OWNER","body":"Here are the `thumbnail` docs:\r\n\r\nhttp://jcupitt.github.io/libvips/API/current/libvips-resample.html#vips-thumbnail"}}
{"actor":{"display_login":"jcupitt"}}