Skip to content

Commit

Permalink
1.3.2: added description and type for picture
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Jul 26, 2022
1 parent ef5b2f2 commit 6578bb8
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 18 deletions.
4 changes: 4 additions & 0 deletions doc/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
opustags
https://github.com/zvezdochiot/opustags [fork](https://github.com/fmang/opustags)

1.3.2 "convert" <zvezdochiot>

added description and type for picture

1.3.1 "convert" <zvezdochiot>

added tool for convert picture to tag
Expand Down
8 changes: 7 additions & 1 deletion doc/opuspic2tag.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH OpusPic2Tag 1 "7 Mar 2019" "1.3.1" "User Manual"
.TH OpusPic2Tag 1 "26 Jul 2022" "1.3.2" "User Manual"
.SH NAME
opuspic2tag \- Convert picture to opus tag
.SH SYNOPSIS
Expand All @@ -13,6 +13,12 @@ opuspic2tag \- Convert picture to opus tag
.B \-h, \-\-help
Display a brief description of the options.
.TP
.B \-d, \-\-desc \fISTRING\fI
description picture
.TP
.B \-t, \-\-type NUM
set image type by 0-20 or keywords, default=3
.TP
.B \-o, \-\-output \fIFILE\fI
Output text file.
.SH EXAMPLE
Expand Down
2 changes: 1 addition & 1 deletion doc/opustags.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH OpusTags 1 "7 Mar 2019" "1.3.1" "User Manual"
.TH OpusTags 1 "26 Jul 2022" "1.3.2" "User Manual"
.SH NAME
opustags \- Opus comment editor
.SH SYNOPSIS
Expand Down
2 changes: 1 addition & 1 deletion package_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PACKAGE_VERSION="1.3.1"
PACKAGE_VERSION="1.3.2"
29 changes: 19 additions & 10 deletions src/clipic.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ const char *usage = "Usage: " UTILS_NAME " [OPTIONS] FILE{.jpg,.png,.gif}\n";
const char *help =
"Options:\n"
" -h, --help print this help\n"
" -d, --desc STRING description picture\n"
" -t, --type NUM set image type by 0-20 or keywords, default=3\n"
" -o, --output FILE write tag to a file (default=stdout)\n";

struct option options[] = {
{"help", no_argument, 0, 'h'},
{"desc", required_argument, 0, 'd'},
{"type", required_argument, 0, 't'},
{"output", required_argument, 0, 'o'},
{NULL, 0, 0, 0}
};
Expand All @@ -34,16 +38,24 @@ int main(int argc, char **argv)
fputs(usage, stdout);
return EXIT_SUCCESS;
}
char *path_picture = NULL, *picture_data = NULL, *path_out = NULL;
char *path_picture = NULL, *picture_data = NULL, *picture_desc = NULL, *path_out = NULL;
const char *error_message;
unsigned long picture_type = 3;
int print_help = 0;
int c;
while((c = getopt_long(argc, argv, "ho:", options, NULL)) != -1)
while((c = getopt_long(argc, argv, "hd:t:o:", options, NULL)) != -1)
{
switch(c){
case 'h':
print_help = 1;
break;
case 'd':
picture_desc = optarg;
break;
case 't':
picture_type = atoi(optarg);
picture_type = (picture_type > 20) ? 3 : picture_type;
break;
case 'o':
path_out = optarg;
break;
Expand All @@ -68,7 +80,7 @@ int main(int argc, char **argv)
if(path_picture != NULL)
{
int seen_file_icons=0;
picture_data = opustags_picture_specification_parse(path_picture, &error_message, &seen_file_icons);
picture_data = opustags_picture_specification_parse(path_picture, &error_message, picture_desc, picture_type, &seen_file_icons);
if(picture_data == NULL)
{
fprintf(stderr,"Not read picture: %s\n", error_message);
Expand All @@ -77,14 +89,10 @@ int main(int argc, char **argv)
FILE *out = NULL;
if(path_out != NULL)
{
char canon_picture[PATH_MAX+1], canon_out[PATH_MAX+1];
if(realpath(path_picture, canon_picture) && realpath(path_out, canon_out))
if(strcmp(path_picture, path_out) == 0)
{
if(strcmp(canon_picture, canon_out) == 0)
{
fputs("error: the input and output files are the same\n", stderr);
return EXIT_FAILURE;
}
fputs("error: the input and output files are the same\n", stderr);
return EXIT_FAILURE;
}
out = fopen(path_out, "w");
if(!out)
Expand Down Expand Up @@ -113,6 +121,7 @@ int main(int argc, char **argv)
}
fwrite(picture_meta, 1, picture_meta_len, out);
free(picture_meta);
fwrite("\n", 1, 1, out);
}
if(out)
fclose(out);
Expand Down
5 changes: 3 additions & 2 deletions src/clitags.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ int main(int argc, char **argv)
fputs(usage, stdout);
return EXIT_SUCCESS;
}
char *path_in, *path_out = NULL, *inplace = NULL, *path_picture = NULL, *picture_data = NULL;
char *path_in, *path_out = NULL, *inplace = NULL, *path_picture = NULL, *picture_desc = NULL, *picture_data = NULL;
const char* to_add[argc];
const char* to_delete[argc];
const char* to_picture[1];
const char *error_message;
unsigned long picture_type = 3;
int count_add = 0, count_delete = 0;
int delete_all = 0;
int set_all = 0;
Expand Down Expand Up @@ -208,7 +209,7 @@ int main(int argc, char **argv)
if(path_picture != NULL)
{
int seen_file_icons=0;
picture_data = opustags_picture_specification_parse(path_picture, &error_message, &seen_file_icons);
picture_data = opustags_picture_specification_parse(path_picture, &error_message, picture_desc, picture_type, &seen_file_icons);
if(picture_data == NULL)
{
fprintf(stderr,"Not read picture: %s\n", error_message);
Expand Down
2 changes: 2 additions & 0 deletions src/opustags.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void opustags_params_extract_jpeg(const unsigned char *data, size_t data_length,

char *opustags_picture_specification_parse(const char *spec,
const char **error_message,
const char *desc,
unsigned long picture_type,
int *seen_file_icons);

#define READ_U32_BE(buf) \
Expand Down
8 changes: 5 additions & 3 deletions src/picture.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@ void opustags_params_extract_jpeg(const unsigned char *data, size_t data_length,
tag.*/
char *opustags_picture_specification_parse(const char *spec,
const char **error_message,
int *seen_file_icons){
const char *desc,
unsigned long picture_type,
int *seen_file_icons)
{
FILE *picture_file;
unsigned long picture_type;
unsigned long width;
unsigned long height;
unsigned long depth;
Expand All @@ -254,11 +256,11 @@ char *opustags_picture_specification_parse(const char *spec,
full specification just from the spec string.
Instead, try to open the file.
If it exists, the user probably meant the file.*/
picture_type=3;
width=height=depth=colors=0;
mime_type=mime_type_end=description=description_end=filename=spec;
is_url=0;
picture_file=fopen(filename,"rb");
if (desc != NULL) description = desc;
if(picture_file==NULL&&strchr(spec,'|')){
const char *p;
char *q;
Expand Down

0 comments on commit 6578bb8

Please sign in to comment.