mirror of
https://github.com/eddyem/SBIG_340.git
synced 2025-12-06 10:45:10 +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 <unistd.h>
|
||||||
#include <libraw/libraw.h>
|
#include <libraw/libraw.h>
|
||||||
#include <gd.h>
|
#include <gd.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "debayer.h"
|
#include "debayer.h"
|
||||||
#include "usefull_macros.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){
|
static int write_jpeg(const char *fname, const uint8_t *data, imstorage *img){
|
||||||
if(!img) return 1;
|
if(!img) return 1;
|
||||||
size_t nx = img->W, ny = img->H;
|
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);
|
gdImageJpeg(im, fp, 90);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
|
modifytimestamp(fname, img);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "imfunctions.h"
|
#include "imfunctions.h"
|
||||||
int write_debayer(imstorage *img, uint16_t black);
|
int write_debayer(imstorage *img, uint16_t black);
|
||||||
|
void modifytimestamp(const char *filename, imstorage *img);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,15 +48,6 @@ double exp_calculated = -1.; // optimal exposition, calculated in histogram save
|
|||||||
* exposition start!
|
* exposition start!
|
||||||
*/
|
*/
|
||||||
#ifndef DAEMON
|
#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!
|
* NON THREAD-SAFE!
|
||||||
|
|||||||
2
socket.c
2
socket.c
@ -66,8 +66,8 @@ static int waittoread(int sock){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}while(1);
|
}while(1);
|
||||||
if(FD_ISSET(sock, &fds)) return 1;
|
|
||||||
if(FD_ISSET(sock, &efds)) return -1; // exception - socket closed
|
if(FD_ISSET(sock, &efds)) return -1; // exception - socket closed
|
||||||
|
if(FD_ISSET(sock, &fds)) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user