Browse Source

* Added switch to control output font size, and updated documentation

accordingly
tags/v0.99.beta14
Jean-Yves Lamoureux jylam 17 years ago
parent
commit
7d7f4c42e1
2 changed files with 30 additions and 6 deletions
  1. +14
    -0
      doc/img2txt.1
  2. +16
    -6
      src/img2txt.c

+ 14
- 0
doc/img2txt.1 View File

@@ -11,6 +11,14 @@ img2txt \- convert images to various text-based coloured files
.B \-H
.I height
]
[
.B \-x
.I font-width
]
[
.B \-y
.I font-height
]
.PD 0
.IP
.PD
@@ -60,6 +68,12 @@ Change output column count. If not given, the default is set to 60.
.B \-H, \-\-height=<height>
Change output line count. If not given, the height is computed to match correct aspect ratio.
.TP
.B \-x, \-\-font-width=<width>
Change output font width. If not given, the default is set to 6. This value will be used for computing aspect ratio.
.TP
.B \-y, \-\-font-height=<height>
Change output font height. If not given, the default is set to 10. This value will be used for computing aspect ratio.
.TP
.B \-b, \-\-brightness=<brightness>
Change image brightness. Default to 1.0.
.TP


+ 16
- 6
src/img2txt.c View File

@@ -49,6 +49,8 @@ static void usage(int argc, char **argv)
fprintf(stderr, " -v, --version\t\t\tVersion of the program\n");
fprintf(stderr, " -W, --width=WIDTH\t\tWidth of resulting image\n");
fprintf(stderr, " -H, --height=HEIGHT\t\tHeight of resulting image\n");
fprintf(stderr, " -x, --font-width=WIDTH\t\tWidth of output font\n");
fprintf(stderr, " -y, --font-height=HEIGHT\t\tHeight of output font\n");
fprintf(stderr, " -b, --brightness=BRIGHTNESS\tBrightness of resulting image\n");
fprintf(stderr, " -c, --contrast=CONTRAST\tContrast of resulting image\n");
fprintf(stderr, " -g, --gamma=GAMMA\t\tGamma of resulting image\n");
@@ -96,7 +98,7 @@ int main(int argc, char **argv)
void *export;
unsigned long int len;
struct image *i;
unsigned int cols = 0, lines = 0;
unsigned int cols = 0, lines = 0, font_width = 6, font_height = 10;
char *format = NULL;
char *dither = NULL;
float gamma = -1, brightness = -1, contrast = -1;
@@ -115,15 +117,17 @@ int main(int argc, char **argv)
{
{ "width", 1, NULL, 'W' },
{ "height", 1, NULL, 'H' },
{ "font-width", 1, NULL, 'x' },
{ "font-height", 1, NULL, 'y' },
{ "format", 1, NULL, 'f' },
{ "dither", 1, NULL, 'd' },
{ "gamma", 1, NULL, 'g' },
{ "brightness", 1, NULL, 'b' },
{ "contrast", 1, NULL, 'c' },
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'v' },
{ "version", 0, NULL, 'v' },
};
int c = mygetopt(argc, argv, "W:H:f:d:g:b:c:h:v", long_options, &option_index);
int c = mygetopt(argc, argv, "W:H:f:d:g:b:c:h:v:x:y:", long_options, &option_index);
if(c == -1)
break;

@@ -135,6 +139,12 @@ int main(int argc, char **argv)
case 'H': /* --height */
lines = atoi(myoptarg);
break;
case 'x': /* --width */
font_width = atoi(myoptarg);
break;
case 'y': /* --height */
font_height = atoi(myoptarg);
break;
case 'f': /* --format */
format = myoptarg;
break;
@@ -184,15 +194,15 @@ int main(int argc, char **argv)
if(!cols && !lines)
{
cols = 60;
lines = cols * i->h * 6 / i->w / 10;
lines = cols * i->h * font_width / i->w / font_height;
}
else if(cols && !lines)
{
lines = cols * i->h * 6 / i->w / 10;
lines = cols * i->h * font_width / i->w / font_height;
}
else if(!cols && lines)
{
cols = lines * i->w * 10 / i->h / 6;
cols = lines * i->w * font_height / i->h / font_width;
}




Loading…
Cancel
Save