javascript – 通过php将Annotorius注释数据从Image Slider保存到mySQL

我需要帮助从 Annotorius Library获取anotation值.我有很多代码(太多要发布)用于在滑块中注释图像.现在我需要获取注释数据(位置,大小和注释)以发布到我的服务器(PHPMysqL).

任何人都可以发布一些我可以学习的示例代码吗?

解决方法

如果我不是误会.您要查找的数据是:
– 位置:x,y
– 尺寸:宽度,高度
评论:注释文本

试试这个:

var datapost = new Array();
//loop all annotation
anno.getAnnotations().forEach(function(element){
 var details = '==============================================================\n';
 details += '\n image      : ' + element.src;
 details += '\n comment    : ' + element.text;

 var geometry = element.shapes[0].geometry;
 var imgObj = new Image();
 imgObj.src = element.src;

 //get position and size by pixel
 var position_x  = Math.round(imgObj.width  * geometry.x);
 var position_y  = Math.round(imgObj.height * geometry.y);
 var size_width  = Math.round(imgObj.width  * geometry.width);
 var size_height = Math.round(imgObj.height * geometry.height);

 details += '\n position_x : ' + position_x;
 details += '\n position_y : ' + position_y;
 details += '\n width      : ' + size_width;
 details += '\n height     : ' + size_height;

 console.log(details);

 //add data to post
 datapost.push({
  'image'      : element.src,'position_x' : position_x,'position_y' : position_y,'width'      : size_width,'height'     : size_height,'comment'    : element.text
 });
});

//post data to the server here
console.log(datapost);

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...