English 中文(简体)
如何在不压缩联合项目的情况下删除EXIF数据?
原标题:How to remove EXIF data without recompressing the JPEG?

我想要将EXIF信息(包括th、元数据、照相信息......所有!)从联合调查组的档案中删除,但我不想加以压缩,因为压制联合调查小组将降低质量,而且通常会增加档案规模。

I m 寻求“Unix/HCH”解决办法,即使使用指挥线也更好。 在可能的情况下,利用图像Magick(变形工具)。 如果无法做到这一点,小 Python、Perl、PHP(或关于六氯环己烷的其他共同语言)的文字就会ok。

还有一个类似的问题,但与NET有关。

最佳回答

冒犯我的工作,用 per字书写,在任何 o子上为你工作。

https://exiftool.org/

使用情况:

exiftool -all= image.jpg

UPDATED - as Peter 下面的章节将删除所有标签。 如果你只是想去除EXIF的标签,那么你就应当使用。

exiftool -EXIF= image.jpg
问题回答

图像:

convert <input file> -strip <output file>

图像Magick有-strip。 参数,但它在保存之前压制图像。 因此,这一参数对我的需求是无用的。

图像Magick论坛的这个专题说明,在图像Magick(每当这一变化时,请发表一份带有链接的评论!)中,没有支持联合小组的无损失业务,并建议使用jpegtran 。 (从校方)

jpegtran -copy none -progressive image.jpg > newimage.jpg
jpegtran -copy none -progressive -outfile newimage.jpg image.jpg

(如果你对回答我自己的问题不持肯定态度,读到,

页: 1

man jhead
jhead -purejpg image.jpg

只有123Kb on/ubuntu,它迅速发展,它只触及EXIF保持形象。 请注意,如果你希望保存其原始档案,你需要制作一份副本。

我最近在C开展了这一项目。 如下守则:

(1) 了解目前形象的方向。

2) 删除<代码>APP1中的所有数据。 (Exif data) and APP2 (Flashpix data) by blanking.

3) 重新编号<代码>APP1 取向标记,将其贴在原有值上。

4) 提供第一个<代码>EOI的标识(图像的电子版),如果是阳性,则对文档进行分类。

首先要指出的一些内容是:

(1) 这一方案用于我的Nikon照相机。 Nikon s JPEG格式为它制作的每个档案的末尾添加了播音。 它们通过创建第二个<编码>EOI标记,将这一数据输入到图像档案的末尾。 通常读到第一个<代码>EOI的标识。 之后,Nikon掌握了我的方案分类信息。

(2) 由于采用Nikon格式,按批次顺序排列如下:big endian。 如果您的图像档案使用little endian,就需要作出一些调整。

3) 在试图使用<代码>ImageMagick以脱节数据时,我注意到,我最后的档案比我开始的多。 这使我相信,<代码>Imagemagick>正在编码你想要删除的数据,并在档案中存放。 我请我老是时装的,但当我从档案中删除一些东西时,我希望文件篇幅会小一些,即使规模也不相同。 任何其他结果都表明数据开采。

这里是法典:

#include <stdio.h>
#include <stdlib.h>
#include <libgen.h>
#include <string.h>
#include <errno.h>

// Declare constants.
#define COMMAND_SIZE     500
#define RETURN_SUCCESS     1
#define RETURN_FAILURE     0
#define WORD_SIZE         15

int check_file_jpg (void);
int check_file_path (char *file);
int get_marker (void);
char * ltoa (long num);
void process_image (char *file);

// Declare global variables.
FILE *fp;
int orientation;
char *program_name;

int main (int argc, char *argv[])
{
// Set program name for error reporting.
    program_name = basename(argv[0]);

// Check for at least one argument.
    if(argc < 2)
    {
        fprintf(stderr, "usage: %s IMAGE_FILE...
", program_name);
        exit(EXIT_FAILURE);
    }

// Process all arguments.
    for(int x = 1; x < argc; x++)
        process_image(argv[x]);

    exit(EXIT_SUCCESS);
}

void process_image (char *file)
{
    char command[COMMAND_SIZE + 1];

// Check that file exists.
    if(check_file_path(file) == RETURN_FAILURE)
        return;

// Check that file is an actual JPEG file.
    if(check_file_jpg() == RETURN_FAILURE)
    {
        fclose(fp);
        return;
    }

// Jump to orientation marker and store value.
    fseek(fp, 55, SEEK_SET);
    orientation = fgetc(fp);

// Recreate the APP1 marker with just the orientation tag listed.
    fseek(fp, 21, SEEK_SET);
    fputc(1, fp);

    fputc(1, fp);
    fputc(18, fp);
    fputc(0, fp);
    fputc(3, fp);
    fputc(0, fp);
    fputc(0, fp);
    fputc(0, fp);
    fputc(1, fp);
    fputc(0, fp);
    fputc(orientation, fp);

// Blank the rest of the APP1 marker with   .
    for(int x = 0; x < 65506; x++)
        fputc(0, fp);

// Blank the second APP1 marker with   .
    fseek(fp, 4, SEEK_CUR);

    for(int x = 0; x < 2044; x++)
        fputc(0, fp);

// Blank the APP2 marker with   .
    fseek(fp, 4, SEEK_CUR);

    for(int x = 0; x < 4092; x++)
        fputc(0, fp);

// Jump the the SOS marker.
    fseek(fp, 72255, SEEK_SET);

    while(1)
    {
// Truncate the file once the first EOI marker is found.
        if(fgetc(fp) == 255 && fgetc(fp) == 217)
        {
            strcpy(command, "truncate -s ");
            strcat(command, ltoa(ftell(fp)));
            strcat(command, " ");
            strcat(command, file);
            fclose(fp);
            system(command);
            break;
        }
    }
}

int get_marker (void)
{
    int c;

// Check to make sure marker starts with 0xFF.
    if((c = fgetc(fp)) != 0xFF)
    {
        fprintf(stderr, "%s: get_marker: invalid marker start (should be FF, is %2X)
", program_name, c);
        return(RETURN_FAILURE);
    }

// Return the next character.
    return(fgetc(fp));
}

int check_file_jpg (void)
{
// Check if marker is 0xD8.
    if(get_marker() != 0xD8)
    {
        fprintf(stderr, "%s: check_file_jpg: not a valid jpeg image
", program_name);
        return(RETURN_FAILURE);
    }

    return(RETURN_SUCCESS);
}

int check_file_path (char *file)
{
// Open file.
    if((fp = fopen(file, "rb+")) == NULL)
    {
        fprintf(stderr, "%s: check_file_path: fopen failed (%s) (%s)
", program_name, strerror(errno), file);
        return(RETURN_FAILURE);
    }

    return(RETURN_SUCCESS);
}

char * ltoa (long num)
{
// Declare variables.
        int ret;
        int x = 1;
        int y = 0;
        static char temp[WORD_SIZE + 1];
        static char word[WORD_SIZE + 1];

// Stop buffer overflow.
        temp[0] =   ;

// Keep processing until value is zero.
        while(num > 0)
        {
                ret = num % 10;
                temp[x++] = 48 + ret;
                num /= 10;
        }

// Reverse the word.
        while(y < x)
        {
                word[y] = temp[x - y - 1];
                y++;
        }

        return word;
}

希望能帮助人们!

我们利用这一方法从森林论坛档案中删除纬度数据:

exiv2 mo -M"del Exif.GPSInfo.GPSLatitude" IMG.TIF where you can use exiv2 -pa IMG.TIF to list all metadata.

www.un.org/Depts/DGACM/index_spanish.htm 方便: 如果你在Windows上,你可以向登记处申请区域评价档案,在地表上安装一个条目,以便你能够通过正确点击档案和选择指挥来轻易地清除元数据。

例如(要求指明在你的计算机上安装可起诉人的道路):


For JPEG,JPG,JPE,JFIF files: command "Remove metadata"
(using
ExifTool, preserves original file as backup)
exiftool -all= image.jpg

JPG-RemoveExif.reg

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERSoftwareClassesjpegfileshellRemoveMetadata]
@="Remove metadata"
[HKEY_CURRENT_USERSoftwareClassesjpegfileshellRemoveMetadatacommand]
@=""C:\Path to\exiftool.exe" -all= "%1""
[HKEY_CURRENT_USERSoftwareClassesjpegfileshellRemoveMetadata]
"Icon"="C:\Path to\exiftool.exe,0"

For PNG files: command "Convert to minified PNG"
(using ImageMagick, changes data overwriting original file)
convert -background none -strip -set filename:n "%t" image.png "%[filename:n].png"

PNG-Minification.reg

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERSoftwareClassespngfileshellConvertToMinifiedPNG]
@="Convert to minified PNG"
[HKEY_CURRENT_USERSoftwareClassespngfileshellConvertToMinifiedPNGcommand]
@=""C:\Path to\convert.exe" -background none -strip -set filename:n "%%t" "%1" "%%[filename:n].png""
[HKEY_CURRENT_USERSoftwareClassespngfileshellConvertToMinifiedPNG]
"Icon"="C:\Path to\convert.exe,0"

相关: PNGs to ICO in context menu.

如果你已经使用jpegoptim,你也可以利用它去除。

jpegoptim -s *




相关问题
Generate assembler code from C file in linux

I would like to know how to generate assembler code from a C program using Unix. I tried the gcc: gcc -c file.c I also used firstly cpp and then try as but I m getting errors. I m trying to build an ...

Function to create the array by reading the file

I am creating scripts which will store the contents of pipe delimited file. Each column is stored in a separate array. I then read the information from the arrays and process it. There are 20 pipe ...

Compare characters at the end of the string C++

This program supposed to find command line arguments entered on Unix which ends with “.exe”. For some reason it doesn t work. Here is the code: int main( int argc, char* argv[] ) { for ( int ...

Batch Job Dependencies Using Open Source/Free Software

I run a large data warehouse plant where we have a lot of nightly jobs running concerruently however many have dependencies on a extract or data load process before they start. Currently we use an ...

Writing application for both Unix and Windows

I ll write a program for Interactive UNIX (http://en.wikipedia.org/wiki/INTERACTIVE_UNIX). But in a year it will be ported to Windows. I ll write it in ANSI C and/or SH-script. When it runs on Windows ...

Development Environment in Windows [closed]

What are your recommendations for setting up a development environment in Windows, especially when not using an IDE. I am attempting to familiarize myself with Windows, and I feel a bit lost. What ...

热门标签