좋아, 내가 할 수있는대로 따라하기 쉽도록 노력하겠습니다.mysql 쿼리에 의해 생성 된 XML에서 참조 된 이미지 압축하기
배경 : PHP를 사용하여 MySQL 데이터베이스에서 ebay 모터 프로에 자동차를 표시하는 XML 피드를 만들고 있습니다. 관련된 모든 세부 정보가 포함 된 xml 파일을 성공적으로 만들었으며 ftp는 내 테스트 서버에 있습니다.
문제점 : 각 차량 사진은 데이터베이스에 regnumber_1.jpg, regnumber_2.jpg로 기록됩니다. 등등, 그리고 각 차량에 연결됩니다. 이미지는 autotrader라는 폴더에 있습니다.
이미지를 autotrader 폴더에서 zip 파일 내의 ebay 폴더에 게시하는 데 문제가 있습니다. mysql 쿼리 (즉 전체 폴더가 아닌)에서 사진을 복사하고 싶습니다.
정확하게 foreach 루프를 수행하지 않았기 때문에 의심 스럽지만 잘하면 누군가가 올바른 방향으로 나를 가리킬 수 있습니까?
//Photos bit...
$destination = 'tmp/ebay';
$filename = 'ebay-photos';
//images array
$row = array();
foreach ($result->images as $images) {
$images = explode(',', $row['images']);
foreach ($images as $image) {
copy('uploads/used-cars/autotrader/' . $image, $destination . $image);
$all_images[] = $image;
}
}
exec('zip -g0 ' . $zip_filename . ' *.jpg *.jpeg');
foreach ($all_images as $image) {
@unlink($destination.$image);
}
$zip_filename = $filename . '.zip';
while ($row = @mysql_fetch_assoc($result)){
$all_images->images as $images);
}
는 XML 비트 작품이며 : 여기 코드는 사전에
while ($row = @mysql_fetch_assoc($result)){
// XML
$node = $dom->createElement("ad");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("vrm",$row['vrm']);
$newnode->setAttribute("make",$row['make']);
$newnode->setAttribute("model",$row['model']);
$newnode->setAttribute("type",$row['type']);
$newnode->setAttribute("consumerPrice",$row['consumerPrice']);
$newnode->setAttribute("numPreviousOwners",$row['numPreviousOwners']);
$newnode->setAttribute("transmission",$row['transmission']);
$newnode->setAttribute("images",$row['images']);
$newnode->setAttribute("numPreviousOwners",$row['numPreviousOwners']);
$newnode->setAttribute("color",$row['color']);
}
$dom->save('tmp/ebay/ebay.xml');
echo $dom->saveXML();
감사합니다!
jpeg와 같은 압축 이미지 압축은 시간 낭비입니다. 운이 좋으면 크기가 10 % 감소합니다. 사물의 이베이 (ebay) 측면의 요구 사항이 아니라면 무엇이든간에 이미지를 부르는 것이 좋습니다. 타르를 사용하면 여전히 파일을 가지고있을 수 있지만 압축하려고 시간을 낭비하지 않아도됩니다. –
안녕하세요. 이베이의 요구 사항으로 zip 파일에 들어갈 이미지가 여러 개 있습니다. – LeeG