Open a file in a program or application and save in another format
이전 댓글 표시
How can a file (i.e. a .jpg image) be opened in a program (i.e. MS. Paint) and saved in a different format (i.e., TIF)?
I'd also appreciate hints to perform more tasks such as resizing the image or using other functions of the program in which the file is opened.
댓글 수: 2
Geoff Hayes
2022년 12월 23일
@Vahid Atashbari - please clarify how your question relates to MATLAB. Why do you want the file to be opened in MS Paint? Are you also asking how to resize (or do whatever) the image using MS Paint too?
Vahid Atashbari
2023년 1월 8일
채택된 답변
추가 답변 (1개)
Sulaymon Eshkabilov
2022년 12월 23일
1 개 추천
You can try with the following functions to save image data - saveas() in an image file and open in MS applications using winopen():
(1) To save your image data displayed in a Figure window using: saveas(gcf, 'IMAGE', 'jpg')
(2) To open the file from MATLAB: winopen('IMAGE.jpg')
댓글 수: 3
Vahid Atashbari
2023년 1월 8일
DGM
2023년 1월 8일
Save images using imwrite() instead of figure capture.
imwrite(myimagevariable,'outputfile.png')
Using figure capture will usually result in the image being crudely resized with nearest-neighbor interpolation, some amount of excess white padding added, and the image potentially changing type (e.g. a binarized, indexed, or grayscale image being converted to RGB). It's destructive, poorly-controlled, and typically unnecessary.
JPG is also destructive and often unnecessary. Using JPG as an intermediate step between the workspace and a (typically) lossless format like TIFF largely defeats the purpose of using a lossless format.
For the specific case of MSPaint, I imagine most of the work that can hypothetically be done programmatically in Paint can also just be done in MATLAB.
For the general case of controlling other applications, I don't know if an arbitrary application supports desired operations through a command line interface or if there is some API to do it. That would require specifics. If you can write an external script to do it, then there you can always run that script via MATLAB.
Vahid Atashbari
2023년 1월 27일
카테고리
도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!