유스 케이스는 데이터베이스에 크기가 조정 된 svg를 저장합니다. 이 질문에는 2 부분이 있습니다.브라우저 기반 로컬 파일 시스템 대 SVG base64 데이터 문자열
로드 된 이미지 파일에서 데이터 문자열을 가져 오는 방법.
캔버스를 통해 데이터 문자열 이미지의 크기를 조정하는 방법.
내가 window.URL.createObjectURL 다음과 같은 코드를 사용 할 수있었습니다() 멋진 문자열을 얻을 수 있지만 각도에서, 내가 잘못 혼합 상태 (UI-라우터)가있을 수 있습니다. 그래서 CONSOLE.LOG에 의해 생성 된 링크를 클릭하면
function createObjectURL() {
console.log('file',file);
return (window.URL) ? window.URL.createObjectURL(file) : window.webkitURL.createObjectURL(file);
};
function revokeObjectURL(url) {
console.log('url',url);
return (window.URL) ? window.URL.revokeObjectURL(url) : window.webkitURL.revokeObjectURL(url);
};
(function myUploadOnChangeFunction() {
console.log('file',file);
var src = createObjectURL(file);
console.log('src',src);
var image = new Image();
console.log('image',image);
src = src.toLowerCase().replace(/'+/g, '').replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "-").replace(/^-+|-+$/g, '');
image.src = src;
console.log('image.src',image.src);
api.testMe = image.src;
return api.testMe;
// Do whatever you want with your image, it's just like any other image
// but it displays directly from the user machine, not the server!
})();
방울 : HTTP % 3A // % 3A9000/66705b7a-148A-4921-a48b-090fd2ceba52 그것이 제공하는 링크입니다.
[잉크 스케이프 (http://inkscape.org/doc/tracing/tutorial- tracing.html) 또는 [Adobe Indesign] (http://www.adobe.com/inspire/2013/09/exporting-svg-illustrator.html)이 도움이 될 수 있습니다. Havent는 좋은 브라우저 기반 변환기를 보았지만 https://cloudconvert.org/png-to-svg를 시도했습니다. –
건배 Alvin, 내 주요 사용 사례는 클라이언트 측 AngularJS CMS 앱에 업로드 크기를 조정하고 저장하는 것입니다. 귀하의 링크는 그것이 가능하다는 것을 보여 주며, 분명히 우리가 화면에서 볼 수있는 어떤 이미지라도 바로 그 품질로 저장 될 수 있습니까? 그래서 html5 캔버스 도구를 사용하여 이미지를 조작하고 최종적으로 벡터 svg base64 문자열을 클라우드 데이터베이스 문서에 업로드 할 수 있습니다. – irth
Emmet 인코딩/디코딩 방식을 이해하는 것이 유리할 수 있습니다. http://docs.emmet.io/actions/base64/ –