/* main program */
int main(int argc, char **argv)
{
/* an image handle */
Imlib_Image image;
/* if we provided < 2 arguments after the command - exit */
if (argc != 3) exit(1);
/* load the image */
image = imlib_load_image(argv[1]);
/* if the load was successful */
if (image)
{
char *tmp;
/* set the image we loaded as the current context image to work on */
imlib_context_set_image(image);
/* set the image format to be the format of the extension of our last */
/* argument - i.e. .png = png, .tif = tiff etc. */
tmp = strrchr(argv[2], '.');
if(tmp)
imlib_image_set_format(tmp + 1);
/* save the image */
imlib_save_image(argv[2]);
}
}
This program use Imlib2 library. In the manual the way for compile is cc imlib2_convert.c -o imlib2_convert `imlib2-config --cflags` `imlib2-config --libs` . I have tried to install imlib2 with nix-shell -p imlib2. But I can’t find the imlib2-config utility.
My question is: How can I compile this program in NixOS?
Thanks!
#include <Imlib2.h> // For Imlib2
#include <stdlib.h> // For exit
#include <string.h> // For strrchr
/* main program */
int main (int argc, char **argv) {
/* an image handle */
Imlib_Image image;
/* if we provided < 2 arguments after the command - exit */
if (argc != 3) exit(1);
/* load the image */
image = imlib_load_image(argv[1]);
/* if the load was successful */
if (image) {
char *tmp;
/* set the image we loaded as the current context image to work on */
imlib_context_set_image(image);
/* set the image format to be the format of the extension of our last */
/* argument - i.e. .png = png, .tif = tiff etc. */
tmp = strrchr(argv[2], '.');
if (tmp)
imlib_image_set_format(tmp + 1);
/* save the image */
imlib_save_image(argv[2]);
}
}