mirror of
https://github.com/eddyem/SBIG_340.git
synced 2025-12-06 02:35:12 +03:00
add timestamp modifying for jpeg files
This commit is contained in:
parent
bf34128607
commit
9a49eca6aa
12
debayer.cpp
12
debayer.cpp
@ -26,10 +26,21 @@
|
||||
#include <unistd.h>
|
||||
#include <libraw/libraw.h>
|
||||
#include <gd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "debayer.h"
|
||||
#include "usefull_macros.h"
|
||||
|
||||
|
||||
void modifytimestamp(const char *filename, imstorage *img){
|
||||
if(!filename) return;
|
||||
struct timespec times[2];
|
||||
memset(times, 0, 2*sizeof(struct timespec));
|
||||
times[0].tv_nsec = UTIME_OMIT;
|
||||
times[1].tv_sec = img->exposetime; // change mtime
|
||||
if(utimensat(AT_FDCWD, filename, times, 0)) WARN(_("Can't change timestamp for %s"), filename);
|
||||
}
|
||||
|
||||
static int write_jpeg(const char *fname, const uint8_t *data, imstorage *img){
|
||||
if(!img) return 1;
|
||||
size_t nx = img->W, ny = img->H;
|
||||
@ -73,6 +84,7 @@ static int write_jpeg(const char *fname, const uint8_t *data, imstorage *img){
|
||||
gdImageJpeg(im, fp, 90);
|
||||
fclose(fp);
|
||||
gdImageDestroy(im);
|
||||
modifytimestamp(fname, img);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ extern "C" {
|
||||
|
||||
#include "imfunctions.h"
|
||||
int write_debayer(imstorage *img, uint16_t black);
|
||||
void modifytimestamp(const char *filename, imstorage *img);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -48,15 +48,6 @@ double exp_calculated = -1.; // optimal exposition, calculated in histogram save
|
||||
* exposition start!
|
||||
*/
|
||||
#ifndef DAEMON
|
||||
#include <time.h>
|
||||
void modifytimestamp(char *filename, imstorage *img){
|
||||
if(!filename) return;
|
||||
struct timespec times[2];
|
||||
memset(times, 0, 2*sizeof(struct timespec));
|
||||
times[0].tv_nsec = UTIME_OMIT;
|
||||
times[1].tv_sec = img->exposetime; // change mtime
|
||||
if(utimensat(AT_FDCWD, filename, times, 0)) WARN(_("Can't change timestamp for %s"), filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* NON THREAD-SAFE!
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user