Take the 2-minute tour ×

I have a linux app programmed in C which uses gdk for image stuff. The images are sent to a remote server through FTP (with libcurl).

Currently I'm saving the images first to a local hard disk with gdk_pixbuf_save, but this seems kinda useless step. How difficult would it be to save the images directly on the remote server? I would also need to use the quality setting of jpg.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

There is a gdk_pixbuf_save_to_buffer that can store data to a gchar buffer.

I wasn't able to quickly find the CURL API associated with FTP put requests; hopefully you'll be familiar enough with CURL to know how to put a file using a buffer as contents.

share|improve this answer
Thanks, I'll look into that! –  drwn Feb 21 '12 at 0:51
Now I was finally able to test this and I ran into a following problem: how do I properly allocate memory for the gchar buffer gdk_pixbuf_save_to_buffer uses, as I don't think I know beforehand how big the resulting jpg will be? I'm also not very familiar with memory management in C. –  drwn Feb 26 '12 at 0:50
Never mind, I figured it out. –  drwn Feb 26 '12 at 1:12
Sorry I didn't see the question about memory allocation; if you want to add a new answer with the details on memory allocation and curl API, that'd be superb, so someone else with a similar question in the future can save the time. –  sarnold Feb 27 '12 at 23:03
I actually made completely another question because i had a bigger problem with the CURL callback function, and there is a great answer given to it. –  drwn Mar 1 '12 at 17:29

Your Answer


