ImageMagick open and write image with qt ans magick++ - c++

Im using Magick++ Library with Qt
Im using the following code to read and write an image:
Image image;
image.read(qPrintable(f.absoluteFilePath()));
image.addNoise(GaussianNoise);
image.magick("png");
image.write("image_name");
Where f.absoluteFilePath is the absolute path for my image
Example: /Users/user/Desktop/test/P1030673.jpg
After the completion of the code, I cannot locate the image named 'image_name'.
I looked into the folder of the first image '/Users/macmini/Desktop/test/' and its not there
I tried to search the image, but it seems is not in my computer.
Where do I go wrong?
How can I save the image in my computer?
is there any way to specify the path that I want the image to be saved?
Thank you

You should find the file saved in the current working directory. If you want to save it elsewhere give an absolute path.

For everyone who might have tha same problem:
Imagemagick will save the images inside the .app bundle
You will not be able to find the image files unless you specify a path inside the read() function
I noticed the following by checking the size of my .app file
It was increased everytime I was trying to save images.

Related

QCameraImageCapture saves to file instead of buffer

I would like to when I capture a photo with my camera it doesn't create a file in the default directory but it uses the buffer instead.
So I have set the capture destination to buffer :cameraImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer)
However it still saves a file in the directory. I'm on Ubuntu 16.04. Do you have any ideas to solve my problem ? Thank you.

ARToolKit Calibration Result Saving Error

I have been using ARToolKit to calibrate my camera, everything went fine until I tried to save the result, it came up with this error:
Error (13): unable to open camera parameters file "camera_para.dat" for writing.
Result too large
Parameter write error!!
I used the ARToolKit's calib_camera example code.
Thank you in advance!
I've actually figured this out...it was just because my ARToolKit was installed in Program Files folder, which is read-only. To save the results successfully, all you need to do is to run as administrator at the beginning.

Deploying a Qt program with a logo to load

I have developed a program for a customer which includes a functionality to save and print PDF files. In this PDF file there should be a company logo attached.
I am using the QPrinter function to both create and print the PDF file. To add the logo I use the function drawPixmap. The logo itself is a JPG file. Originally I just added the file to my program folder and used QDir::currentPath() + "/" + "logoName.jpg". It worked flawlessly on my computer but at the customer it can not load the file using the load() function from QPixmap:
QPixmap companyLogo;
companyLogo.load(QStringPathToFile);
I have verified that the string is correct using entryInfoList() and compared it to the path I send to QPixmap.
I learned about resource files in Qt and how you could add a resource, like an image, to the binary. Again, it works flawlessly on my PC but at the customers PC it fails to load. I have verified the behavior on a secondary PC here in the company.
companyLogo.load( ":/logo/CompanyLogo.jpg" )
It seems like a such simple thing to do. But I am always hit a wall with this logo. Do anyone have any information how I can get this logo/image to load properly when deploying my Qt program to another PC?
You have to deploy jpeg plugin from /plugins/imageformats/qjpeg.dll
Have a look here about how to deploy on windows

Unable to load files from sub-directory, wondering if it's IDE specific

I'm using Qt Creator to design a game, trying to add a simple audio player to play whenever the function is called.
The game will be used on another computer but the entire Snake directory will be moved so I'm wondering the best way to code this so that it can be played anywhere with the audio.
The mp3 is located in the sub directory "scripts/byte.mp3" but I'm wondering if I'm misusing the URL pathing. I've tried "./scripts/byte.mp3" as well as "//scripts/byte.mp3" but it just can't seem to find the file unless I do the entire path.
Wondering what is the right way to code it to find the file.
void GLWidget::playAudio()
{
audioPlayer->setMedia(QUrl::fromLocalFile("C:/Users/Jim/Documents/Snake/sounds/byte.mp3"));
audioPlayer->setVolume(50);
audioPlayer->play();
}

Qt save a QImage to a relative location

I'm using QImage.save to save an image of my OpenGL framebuffer to disk. If I just call save("plot.jpg"), I have no idea where the image ends up. It's not in the application directory. I can call save("/Users/wallacer/desktop/plot.jpg") to save the file on my desktop, but obviously that's no good for running on anyone else's machine. Is there an environment variable or something I can use to save the QImage to a known location? Or is there a way I can just save the image to the directory the application resides in?
This seems obvious, but I can't seem to find anything about choosing a save location in the docs.
Thanks!
You could use QDir::homePath or QDir::home to get a relative (and IIRC, platform independent) path.
ETA: Or the applcation's current path should be in QDir::currentPath.
Ok I feel dumb. I'm just going to use a file dialog to allow the user to select a directory to save the image file in.