สอบถาม การอ่านข้อมูลไฟล์ภาพ

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
Chayyim
PHP Sr. Member
PHP Sr. Member
โพสต์: 79
ลงทะเบียนเมื่อ: 16/05/2012 4:01 pm
ติดต่อ:

สอบถาม การอ่านข้อมูลไฟล์ภาพ

โพสต์ที่ยังไม่ได้อ่าน โดย Chayyim »

อยากทราบวิธีการอ่านข้อมูลจากไฟล์ภาพ jpeg ครับ เช่น เมื่อเราอัพโหลดไฟล์เข้าไปแล้วก็จะแสดงรายละเอียดเกี่ยวกับภาพเช่น รุ่นของกล้องที่ใช้ถ่ายภาพ ความเร็วชัตเตอร์ประมาณนี้ครับ
ภาพตัวอย่าง
ภาพตัวอย่าง
ttt.jpg (7.51 KiB) Viewed 2490 times
ภาพประจำตัวสมาชิก
Chayyim
PHP Sr. Member
PHP Sr. Member
โพสต์: 79
ลงทะเบียนเมื่อ: 16/05/2012 4:01 pm
ติดต่อ:

Re: สอบถาม การอ่านข้อมูลไฟล์ภาพ

โพสต์ที่ยังไม่ได้อ่าน โดย Chayyim »

ดันนิส มีใครพอจะรู้ไหมครับ
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41384
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: สอบถาม การอ่านข้อมูลไฟล์ภาพ

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

กระทู้เก่ามี ครับลองค้นดู
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
tohkai_php
PHP Sr. Member
PHP Sr. Member
โพสต์: 95
ลงทะเบียนเมื่อ: 10/04/2012 9:09 am

Re: สอบถาม การอ่านข้อมูลไฟล์ภาพ

โพสต์ที่ยังไม่ได้อ่าน โดย tohkai_php »

โค้ด: เลือกทั้งหมด

// Create an Image object. 
Image image = new Bitmap(@"c:\FakePhoto.jpg");

// Get the PropertyItems property from image.
PropertyItem[] propItems = image.PropertyItems;

// Set up the display.
Font font = new Font("Arial", 12);
SolidBrush blackBrush = new SolidBrush(Color.Black);
int X = 0;
int Y = 0;

// For each PropertyItem in the array, display the ID, type, and  
// length. 
int count = 0;
foreach (PropertyItem propItem in propItems)
{
    e.Graphics.DrawString(
    "Property Item " + count.ToString(),
    font,
    blackBrush,
    X, Y);

    Y += font.Height;

    e.Graphics.DrawString(
       "   iD: 0x" + propItem.Id.ToString("x"),
       font,
       blackBrush,
       X, Y);

    Y += font.Height;

    e.Graphics.DrawString(
       "   type: " + propItem.Type.ToString(),
       font,
       blackBrush,
       X, Y);

    Y += font.Height;

    e.Graphics.DrawString(
       "   length: " + propItem.Len.ToString() + " bytes",
       font,
       blackBrush,
       X, Y);

    Y += font.Height;

    count++;
}
// Convert the value of the second property to a string, and display  
// it.
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
string manufacturer = encoding.GetString(propItems[1].Value);

e.Graphics.DrawString(
   "The equipment make is " + manufacturer + ".",
   font,
   blackBrush,
   X, Y);
จะได้

โค้ด: เลือกทั้งหมด

Property Item 0

id: 0x320

type: 2

length: 16 bytes

Property Item 1

id: 0x10f

type: 2

length: 17 bytes

Property Item 2

id: 0x110

type: 2

length: 7 bytes

Property Item 3

id: 0x9003

type: 2

length: 20 bytes

Property Item 4

id: 0x829a

type: 5

length: 8 bytes

Property Item 5

id: 0x5090

type: 3

length: 128 bytes

Property Item 6

id: 0x5091

type: 3

length: 128 bytes

The equipment make is Northwind Camera. 
แล้วต้องไปแปลง ASCII อีกทีนะครับ
tohkai_php
PHP Sr. Member
PHP Sr. Member
โพสต์: 95
ลงทะเบียนเมื่อ: 10/04/2012 9:09 am

Re: สอบถาม การอ่านข้อมูลไฟล์ภาพ

โพสต์ที่ยังไม่ได้อ่าน โดย tohkai_php »

โค้ด: เลือกทั้งหมด

<?php
echo "test1.jpg:<br />\n";
$exif = exif_read_data('tests/test1.jpg', 'IFD0');
echo $exif===false ? "No header data found.<br />\n" : "Image contains headers<br />\n";

$exif = exif_read_data('tests/test2.jpg', 0, true);
echo "test2.jpg:<br />\n";
foreach ($exif as $key => $section) {
    foreach ($section as $name => $val) {
        echo "$key.$name: $val<br />\n";
    }
}
?>
จะได้

โค้ด: เลือกทั้งหมด

test1.jpg:
No header data found.
test2.jpg:
FILE.FileName: test2.jpg
FILE.FileDateTime: 1017666176
FILE.FileSize: 1240
FILE.FileType: 2
FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, COMMENT
COMPUTED.html: width="1" height="1"
COMPUTED.Height: 1
COMPUTED.Width: 1
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 1
COMPUTED.UserComment: Exif test image.
COMPUTED.UserCommentEncoding: ASCII
COMPUTED.Copyright: Photo (c) M.Boerger, Edited by M.Boerger.
COMPUTED.Copyright.Photographer: Photo (c) M.Boerger
COMPUTED.Copyright.Editor: Edited by M.Boerger.
IFD0.Copyright: Photo (c) M.Boerger
IFD0.UserComment: ASCII
THUMBNAIL.JPEGInterchangeFormat: 134
THUMBNAIL.JPEGInterchangeFormatLength: 523
COMMENT.0: Comment #1.
COMMENT.1: Comment #2.
COMMENT.2: Comment #3end
THUMBNAIL.JPEGInterchangeFormat: 134
THUMBNAIL.Thumbnail.Height: 1
THUMBNAIL.Thumbnail.Height: 1
น่าจะได้สักวิธี เหอะๆ
ภาพประจำตัวสมาชิก
Chayyim
PHP Sr. Member
PHP Sr. Member
โพสต์: 79
ลงทะเบียนเมื่อ: 16/05/2012 4:01 pm
ติดต่อ:

Re: สอบถาม การอ่านข้อมูลไฟล์ภาพ

โพสต์ที่ยังไม่ได้อ่าน โดย Chayyim »

ขอบคุณมากครับ เดี๋ยวขอลองก่อนนะครับ
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 127