Skip to content

Commit cab085e

Browse files
committed
first commit
0 parents  commit cab085e

20 files changed

+1023
-0
lines changed

freeimage.c

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* Compile with:
2+
*
3+
* gcc freeimage.c -lfreeimage
4+
*
5+
* */
6+
7+
#include <FreeImage.h>
8+
9+
int
10+
main (int argc, char **argv)
11+
{
12+
FIBITMAP *t1;
13+
FIBITMAP *t2;
14+
int width;
15+
int height;
16+
17+
FreeImage_Initialise (FALSE);
18+
19+
t1 = FreeImage_Load (FIF_TIFF, argv[1], TIFF_DEFAULT);
20+
21+
width = FreeImage_GetWidth (t1);
22+
height = FreeImage_GetHeight (t1);
23+
24+
t2 = FreeImage_Copy (t1, 100, 100, width - 100, height - 100);
25+
FreeImage_Unload (t1);
26+
27+
t1 = FreeImage_Rescale (t2, (width - 200) * 0.9, (height - 200) * 0.9,
28+
FILTER_BILINEAR);
29+
FreeImage_Unload (t2);
30+
31+
/* FreeImage does not have a sharpen operation, so we skip that.
32+
* */
33+
34+
FreeImage_Save (FIF_TIFF, t1, argv[2], TIFF_DEFAULT);
35+
FreeImage_Unload (t1);
36+
37+
FreeImage_DeInitialise ();
38+
39+
return 0;
40+
}
41+

gegl.c

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/* compile with
2+
3+
gcc -g -Wall gegl.c `pkg-config gegl --cflags --libs`
4+
5+
*/
6+
7+
#include <stdio.h>
8+
#include <stdlib.h>
9+
10+
#include <gegl.h>
11+
12+
int
13+
main (int argc, char **argv)
14+
{
15+
GeglNode *gegl, *load, *crop, *scale, *sharp, *save;
16+
17+
gegl_init (&argc, &argv);
18+
19+
if (argc != 3)
20+
{
21+
fprintf (stderr, "usage: %s file-in file-out\n", argv[0]);
22+
exit (1);
23+
}
24+
25+
gegl = gegl_node_new ();
26+
27+
load = gegl_node_new_child (gegl,
28+
"operation", "gegl:load",
29+
"path", argv[1],
30+
NULL);
31+
printf( "load is node %p\n", load );
32+
33+
crop = gegl_node_new_child (gegl,
34+
"operation", "gegl:crop",
35+
"x", 100.0,
36+
"y", 100.0,
37+
"width", 4800.0,
38+
"height", 4800.0,
39+
NULL);
40+
printf( "crop is node %p\n", crop );
41+
42+
scale = gegl_node_new_child (gegl,
43+
"operation", "gegl:scale",
44+
"x", 0.9,
45+
"y", 0.9,
46+
"filter", "linear",
47+
"hard-edges", FALSE,
48+
NULL);
49+
printf( "scale is node %p\n", scale );
50+
51+
sharp = gegl_node_new_child (gegl,
52+
"operation", "gegl:unsharp-mask",
53+
"std-dev", 1.0, // diameter 7 mask in gegl
54+
NULL);
55+
printf( "sharp is node %p\n", sharp );
56+
57+
save = gegl_node_new_child (gegl,
58+
"operation", "gegl:save",
59+
//"operation", "gegl:png-save",
60+
//"bitdepth", 8,
61+
"path", argv[2],
62+
NULL);
63+
printf( "save is node %p\n", save );
64+
65+
gegl_node_link_many (load, crop, scale, sharp, save, NULL);
66+
67+
//gegl_node_dump( gegl, 0 );
68+
69+
gegl_node_process (save);
70+
71+
//gegl_node_dump( gegl, 0 );
72+
73+
g_object_unref (gegl);
74+
75+
gegl_exit ();
76+
77+
return (0);
78+
}

gegl.xml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
<?xml version='1.0' encoding='UTF-8'?>
3+
<gegl>
4+
5+
<node operation='gegl:unsharp-mask'>
6+
<params>
7+
<param name='std-dev'>0.1</param>
8+
</params>
9+
</node>
10+
11+
<node operation='gegl:scale'>
12+
<params>
13+
<param name='filter'>linear</param>
14+
<param name='hard-edges'>false</param>
15+
<param name='x'>0.9</param>
16+
<param name='y'>0.9</param>
17+
</params>
18+
</node>
19+
20+
<node operation='gegl:crop'>
21+
<params>
22+
<param name='x'>100</param>
23+
<param name='y'>100</param>
24+
<param name='width'>4800</param>
25+
<param name='height'>4800</param>
26+
</params>
27+
</node>
28+
29+
<node operation='gegl:load'>
30+
<params>
31+
<param name='path'>wtc_small.png</param>
32+
</params>
33+
</node>
34+
</gegl>

gm.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
gm convert $1 \
6+
-shave 100x100 \
7+
-resize 90x90% \
8+
-convolve "-1, -1, -1, -1, 16, -1, -1, -1, -1" \
9+
$2

im.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# we crop on load, it's a bit quicker and saves some memory
4+
# we can't crop 100 pixels with the crop-on-load syntax, so we have to
5+
# find the width and height ourselves
6+
width=`header -f Xsize $1`
7+
height=`header -f Ysize $1`
8+
9+
width=$((width - 200))
10+
height=$((height - 200))
11+
12+
set -x
13+
14+
convert "$1[${width}x${height}+100+100]" \
15+
-resize 90x90% \
16+
-convolve "-1, -1, -1, -1, 16, -1, -1, -1, -1" \
17+
$2

is.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/ruby
2+
3+
# gem install image_science
4+
5+
require 'rubygems'
6+
require 'image_science'
7+
8+
ImageScience.with_image(ARGV[0]) do |img|
9+
img.with_crop(100, 100, img.width() - 100, img.height() - 100) do |crop|
10+
crop.resize(crop.width() * 0.9, crop.height() * 0.9) do |small|
11+
small.save(ARGV[1])
12+
end
13+
end
14+
end

netpbm.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
cat > mask <<EOF
4+
P2
5+
3 3
6+
32
7+
14 14 14
8+
14 48 14
9+
14 14 14
10+
EOF
11+
12+
tifftopnm $1 | \
13+
pnmcut -left 100 -right -100 -top 100 -bottom -100 | \
14+
pnmscale 0.9 | \
15+
pnmconvol mask | \
16+
pnmtotiff -truecolor -color > $2

0 commit comments

Comments
 (0)