Menu

Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Thursday, April 2, 2020

[Blogger] วิธีการตั้งค่า Default Facebook Thumbnail สำหรับ Blogger
[Blogger] How to Set Default Facebook Thumbnail for Blogger

Default Facebook Thumbnail จะถูกใช้เมื่อเราแชร์โพสต์ของเราไปยัง Facebook แล้วโพสต์นั้นไม่มีรูปภาพประกอบ Facebook จะดึงข้อมูลภาพที่เราตั้งค่านี้มาแสดงในลิ้งค์แทน

วิธีการตั้งค่าภาพ Thumbnail ตั้งต้นเป็นดังนี้
  1. เข้าไปที่ Theme 
  2. เลือกเมนู Edit HTML 
  3. Copy script ด้านล่างไปใส่ไว้ในส่วนของ head ของ theme
    <b:if cond='data:blog.postImageUrl'>
    <meta expr:content='&quot;&quot; + data:blog.postImageUrl' property='og:image'/>
    <b:else/>
    <meta content= 'image_url' property='og:image'/>
    </b:if>
    
  4. แทนที่ image_url ใน script ข้างต้นด้วย URL ของรูปที่ต้องการ
  5. รอเวลาให้ Facebook อัพเดตข้อมูล ซึ่งใช้เวลาประมาณ 24 ชั่วโมง
หมายเหตุ สำหรับคนที่ไม่ต้องการรอ Facebook อัพเดตตามเวลา สามารถเข้าไปอ่านข้อมูลเพิ่มเติมได้ที่ [Facebook] วิธีการอัพเดตรูปภาพและรายละเอียดของ Link บน Facebook แบบ Manual

Tuesday, March 10, 2020

[Docker - MySQL] การใช้ Docker Image MySQL โดยไม่ระบุเลขเวอร์ชั่นของ Patch ใน Tag อาจทำให้ได้ Docker Image เวอร์ชั่นที่เราไม่ได้คาดการณ์ไว้
[Docker - MySQL] Using Docker Image MySQL without Patch Version Number in Tag May Cause Using Unpredictable Docker Image Version

หลังจากที่ใช้ Docker Image สำหรับ MySQL 5.7 มาหลายโปรเจค 

วันนึงมีโปรเจคที่ต้องรัน SQL เพื่อ insert ข้อมูลภาษาไทยลงฐานข้อมูล ปรากฏว่า SQL ดังกล่าวสามารถรันบน environment ที่เป็น  UAT ได้ แต่ไม่สามารถรันบน Production ได้ ทั้งที่โค้ดและเลข Tag ของ Docker Image ก็เป็นเวอร์ชั่นเดียวกัน

หลังจากหาสาเหตุอยู่นาน พบว่า ถึงแม้จะใช้เลข Docker Tag เดียวกัน คือ 5.7 แต่เวอร์ชั่นของ MySQL ภายในแต่ละ Docker Image แตกต่างกัน ดังรูปข้างล่าง

Image mysql:5.7 ที่ถูกสร้างวันที่ 12/12/2017 จะใช้ MySQL version 5.7.20

Tuesday, October 29, 2019

[Batch Script] วิธีการ Disable การเปลี่ยนภาพพื้นหลังหน้าจอ
[Batch Script] How to Disable Changing Desktop Background

กรณีที่เราต้องการตั้งค่าการเปลี่ยนภาพพื้นหลังหน้าจอผ่าน Batch Script เราจำเป็นต้องเปลี่ยนค่าของ Registry แทนการตั้งค่าผ่าน UI

ขั้นแรก เราต้องหาให้ได้ว่า Registry ตัวใดที่ควบคุมการตั้งค่าการเปลี่ยนภาพพื้นหลัง ซึ่งสามารถหาได้จากลิ้งค์ข้างล่างนี้
How to stop people from changing your Windows 10 desktop wallpaper

ขั้นต่อไป เราต้องเขียน Batch Script ที่มีคำสั่งตามด้านล่างนี้ เพื่อเพิ่ม Key และ Value ของ Registry ข้างต้น
REG ADD HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\ActiveDesktop /f /v NoChangingWallPaper /t REG_DWORD /d 1
สามารถอ่านเพิ่มเติมได้ที่ Batch Script - Adding to the Registry

กรณีที่เราต้องการลบการตั้งค่าข้างต้น เราสามารถรันคำสั่งตามด้านล่างนี้ใน PowerShell
REG DELETE HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\ActiveDesktop /f /v NoChangingWallPaper
สามารถอ่านเพิ่มเติมได้ที่ Batch Script - Deleting from the Registry

Tuesday, October 22, 2013

[EmguCV] วิธีการตั้งค่า EmguCV สำหรับ Visual C#
[EmguCV] How to Set EmguCV for Visual C#

ดาวน์โหลด EmguCV จาก http://sourceforge.net/projects/emgucv/ แล้วติดตั้ง
Download EmguCV from http://sourceforge.net/projects/emgucv/ then install

สร้างโปรเจคใหม่เป็น Windows Form Application
Create new Window Form Application project

เพิ่มไลบรารี่ EmguCV โดยไปที่ Solution Explorer คลิกขวาที่แฟ้ม References แล้วเลือกAdd Reference…
Add EmguCV Library by right click on References within Solution Explorer then select Add Reference... 

Wednesday, October 16, 2013

[EmguCV] การแปลงภาพแบบ Affine
[EmguCV] Affine Transformation

การแปลงภาพแบบ Affine คือ การฉายจุดลงบนฉากรับภาพตามแนวเส้นขนาน นั่นคือ การแปลงภาพที่ยังคงรักษาความขนานของเส้นเอาไว้
Affine transformation is the projection of points onto the image plane along parallel.

ขั้นแรก โหลดภาพตั้งต้นเข้าตัวแปร img
First, load a source image to img 
  1. Image<Bgr, byte> img = new Image<Bgr, byte>(image_path);
Source Image

Tuesday, October 15, 2013

[EmguCV] วิธีการเข้าถึงพิกเซลของภาพ
[EmguCV] How to Access Pixels of Image

สมมติให้
Suppose that
  1. Image<Bgr,byte> img = new Image<Bgr,byte>();

มีสองวิธีสำหรับการเข้าถึงพิกเซลตำแหน่งแถวที่ y และหลักที่ x ของ img
There are two ways to access the pixel on the y-th row and x-th column of img

Wednesday, October 9, 2013

[EmguCV] การแปลงภาพแบบ Perspective
[EmguCV] Perspective Transformation

การแปลงภาพแบบ Perspective คือ การฉายจุดลงบนฉากรับภาพตามแนวเส้นที่พุ่งออกมาจากจุดจุดหนึ่งที่เรียกว่า จุดศูนย์กลางการฉาย
Perspective transformation is the projection of points onto the image plane along lines that emanate from a single point, called the center of projection.

ขั้นแรก โหลดภาพตั้งต้นเข้าตัวแปร img
First, load a source image to img 
  1. Image<Bgr, byte> img = new Image<Bgr, byte>(image_path);
Source image

Tuesday, June 18, 2013

[AS3] วิธีการบันทึกภาพ โดยไม่แสดงไฟล์ไดอะล็อก
[AS3] How to Save an Image without File Dialog

ถ้าใช้ Adobe Flash Player ไม่สามารถทำได้
If Adobe Flash Player is used, it is impossible.

อย่างไรก็ตาม มันสามารถที่จะทำได้สำหรับ Adobe Air Player
However, it is possible for Adobe Air Player

สมมติว่า imgByteData เป็นตัวแปรประเภท ByteArray ของภาพ PNG ที่จะบันทึก
Assume that imgByteData is ByteArray of PNG image which will be saved
  1. import flash.filesystem.*;
  2. ...
  3. var fs:FileStream=new FileStream();
  4. fs.open(new File("C:/img.png"), FileMode.WRITE);
  5. fs.writeBytes(imgByteData);
  6. fs.close();

[AS3] วิธีการบันทึกสกรีนเป็นภาพ
[AS3] How to Save Screen to an Image

ขั้นแรกอ่านข้อมูลบิทแมพจากสกรีน
First, get bitmap data from screen
  1. import flash.display.*;
  2. import flash.utils.ByteArray;
  3. ...
  4. var bitmapData:BitmapData = new BitmapData(this.width, this.height);
  5. bitmapData.draw(this);

ถัดมาทำการเข้ารหัสข้อมูลบิทแมพด้วยตัวเข้ารหัสภาพ
Next, encode bitmap data with image encoder

Friday, June 7, 2013

[OpenCV] วิธีเล่นวิดีโอจากไฟล์
[OpenCV] How to Play Video From File

  1. CvCapture* capture=cvCreateFileCapture("E:/Wildlife.wmv");
  2. IplImage* img;
  3. char c;

  4. double frame_width=cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH );
  5. double frame_height=cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT  );
  6. double fps=cvGetCaptureProperty(capture,CV_CAP_PROP_FPS  );
  7. printf("%f %f %f",frame_width, frame_height,fps);

  8. cvNamedWindow("test",1);
  9. img=cvQueryFrame(capture);
  10. while(img){
  11. cvShowImage("test",img);
  12. c=cvWaitKey(30);
  13. if(c==27)
  14. break;
  15. img=cvQueryFrame(capture);
  16. }
  17. cvReleaseCapture(&capture);

[OpenCV] วิธีการดึงภาพจากกล้อง
[OpenCV] How to Capture Image From Camera

  1. CvCapture* capture=cvCreateCameraCapture(0);
  2. IplImage* img;
  3. char c;

  4. cvNamedWindow("test",1);
  5. while(true){
  6.   img=cvQueryFrame(capture);
  7.   cvShowImage("test",img);
  8.   c=cvWaitKey(30);
  9.   if(c==27)
  10.     break;
  11. }
  12. cvReleaseCapture(&capture);

Tuesday, June 4, 2013

[AS3] วิธีการโหลดภาพเข้า Movie Clip
[AS3] How to Load Image into Movie Clip

ในคอนสตรัคเตอร์ของคลาส movie clip ให้ใส่โค้ดตามด้านล่าง
In the constructor of movie clip class, add the code as below
  1. var loader:Loader = new Loader();
  2. loader.load(new URLRequest('image path'));
  3. addChild(loader);

รูปภาพจะถูกโหลดจาก image path และถูกใส่เป็น child ใน movie clip นี้
The image will be loaded from image path and added to be child of this movie clip

หมายเหตุ: อย่าลืม import flash.net.URLRequest;
Notice: you must import flash.net.URLRequest;