Skip to content

Commit

Permalink
Merge pull request #170 from tshradheya/CollateV1.4
Browse files Browse the repository at this point in the history
Collate v1.4
  • Loading branch information
tshradheya authored Nov 1, 2017
2 parents 5bdec45 + 460aa5b commit dfbac04
Show file tree
Hide file tree
Showing 4 changed files with 3,570 additions and 0 deletions.
57 changes: 57 additions & 0 deletions collated/main/tshradheya-unused.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# tshradheya-unused
###### \java\seedu\address\commons\events\storage\ReadAndStoreImage.java
``` java
package seedu.address.commons.events.storage;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_IMAGE;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import seedu.address.logic.commands.DisplayPictureCommand;
import seedu.address.logic.parser.exceptions.ImageException;

/**
* To read image from specified path and store in @file resources/pictures
*/
public class ReadAndStoreImage {

/**
* @param path
* @return uniquePath new path in directory
*/
public String execute(String path, int newPath) throws IOException {

File fileToRead = null;
BufferedImage image = null;

File fileToWrite = null;

String uniquePath = null;

try {
fileToRead = new File(path);
image = new BufferedImage(963, 640, BufferedImage.TYPE_INT_ARGB);
image = ImageIO.read(fileToRead);

uniquePath = Integer.toString(newPath);

fileToWrite = new File("src\\main\\resources\\pictures\\" + uniquePath + ".jpg");
ImageIO.write(image, "jpg", fileToWrite);


} catch (IOException e) {
throw new ImageException(String.format(MESSAGE_INVALID_IMAGE,
DisplayPictureCommand.MESSAGE_IMAGE_PATH_FAIL));
}

return uniquePath;

}


}
```
Loading

0 comments on commit dfbac04

Please sign in to comment.