phantomjs에는 viewport 조절 기능이 있지만,

기본 chrome headless에서 없다. 따라서 아래와 같이 nodejs를 개발해야 한다.


https://medium.com/@dschnr/using-headless-chrome-as-an-automated-screenshot-tool-4b07dffba79a


참고로 python쪽을 찾아보려 했지만.. 없다.

(chrome의 remote api인 cproto 라는 게 있지만 더 이상 개발되지 않아서 쓸모가 없다. )


nodejs로 개발해야 할 듯하다. 



Posted by '김용환'
,


Java/Spring에서 이미지를 다운로드하는 예시이다.

byte[]로 다운받고 java.nio.file.Files, Paths를 사용해 다운로드받는다. 


@Service
public class Downloader {

@Autowired
private RestTemplate restTemplate;

public void download(String url) throws Exception {

byte[] binary = restTemplate.getForObject(url, byte[].class);
String fileformat = String.format("image.jpg");
Files.write(Paths.get(fileformat), binary);
}

}


Posted by '김용환'
,


phantomjs 가 2018년 4월에 멈춰졌기로 확인해봤다니..


기존의 고생한 것도 있고. headless chrome 때문에 옮겼다고 한다.


https://groups.google.com/forum/#!topic/phantomjs/9aI5d-LDuNE


Hi,


I want to make an announcement.


I think people will switch to it, eventually. Chrome is faster and more stable than PhantomJS. And it doesn't eat memory like crazy.

I don't see any future in developing PhantomJS. Developing PhantomJS 2 and 2.5 as a single developer is a bloody hell.
Even with recently released 2.5 Beta version with new and shiny QtWebKit, I can't physically support all 3 platforms at once (I even bought the Mac for that!). We have no support.
From now, I am stepping down as maintainer. If someone wants to continue - feel free to reach me.

I want to give credits to Ariya, James and Ivan! It was the pleasure to work with you. Cheers!
I also want to say thanks to all people who supported and tried to help us. Thank you!

With regards,

Vitaly.


Posted by '김용환'
,