Get terminal settings before reconnecting stdout
This commit is contained in:
parent
02a5601466
commit
4ac6eb96d8
@ -7,7 +7,7 @@
|
|||||||
#include "pixels.hpp"
|
#include "pixels.hpp"
|
||||||
|
|
||||||
static std::string resize_str() {
|
static std::string resize_str() {
|
||||||
sc::term t {STDERR_FILENO};
|
sc::term t {STDOUT_FILENO};
|
||||||
int cols = t.cols() - 1;
|
int cols = t.cols() - 1;
|
||||||
int rows = t.rows() * 2 - 4;
|
int rows = t.rows() * 2 - 4;
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -24,11 +24,12 @@ void convert(const std::string& path) { // try to convert to ppm using ImageMagi
|
|||||||
throw std::runtime_error {"could not fork"};
|
throw std::runtime_error {"could not fork"};
|
||||||
|
|
||||||
case 0: { // child
|
case 0: { // child
|
||||||
|
std::string resize {resize_str()};
|
||||||
|
|
||||||
throw_if_min1(dup2(pfd[1], STDOUT_FILENO));
|
throw_if_min1(dup2(pfd[1], STDOUT_FILENO));
|
||||||
throw_if_min1(close(pfd[0]));
|
throw_if_min1(close(pfd[0]));
|
||||||
throw_if_min1(close(pfd[1]));
|
throw_if_min1(close(pfd[1]));
|
||||||
|
|
||||||
std::string resize {resize_str()};
|
|
||||||
int res = execlp("magick", "magick", path.c_str(), "-resize", resize.c_str(), "ppm:-", nullptr);
|
int res = execlp("magick", "magick", path.c_str(), "-resize", resize.c_str(), "ppm:-", nullptr);
|
||||||
if (res == -1) { // probably "magick" not found, try "convert"
|
if (res == -1) { // probably "magick" not found, try "convert"
|
||||||
res = execlp("convert", "convert", path.c_str(), "-resize", resize.c_str(), "ppm:-", nullptr);
|
res = execlp("convert", "convert", path.c_str(), "-resize", resize.c_str(), "ppm:-", nullptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user